Remembering a sequence of Events
Prestyman
Posts: 5
Hello.
I am hoping someone can tell me whether the following is possible with the BASIC Stamp:
I would like to have·the stamp to "remember" a sequence of user input events, and then play those events back when required.·Also, the sequence should be able to be reprogrammed at any time.· For sake of clarity, I'll give a simple·example, and then I can expand the idea.
I have two switches, one for·"set"·and one for "run".· I also have a pushbutton that turns an LED on and off.···When in "set" mode, I would like to have the stamp monitor the LED pushbutton, recording the sequence of on/off switching with the duration of time in between each.
At this point I need to be able to shut the unit off, since it is now "programmed." At a later date, I would like to turn it on to "run" the sequence of the on/off switching of the LED.· And of course, at anytime·it should be able to be switched back to "set" and have it memorize a new sequence of button pushes.
Is this possible?· If so, could someone point me in the right direction?
Thanks,
Clinton
I am hoping someone can tell me whether the following is possible with the BASIC Stamp:
I would like to have·the stamp to "remember" a sequence of user input events, and then play those events back when required.·Also, the sequence should be able to be reprogrammed at any time.· For sake of clarity, I'll give a simple·example, and then I can expand the idea.
I have two switches, one for·"set"·and one for "run".· I also have a pushbutton that turns an LED on and off.···When in "set" mode, I would like to have the stamp monitor the LED pushbutton, recording the sequence of on/off switching with the duration of time in between each.
At this point I need to be able to shut the unit off, since it is now "programmed." At a later date, I would like to turn it on to "run" the sequence of the on/off switching of the LED.· And of course, at anytime·it should be able to be switched back to "set" and have it memorize a new sequence of button pushes.
Is this possible?· If so, could someone point me in the right direction?
Thanks,
Clinton
Comments
You set the original sequence with DATA statements. You can read the sequence with "READ"
You can then update the sequence with "WRITE". But don't "WRITE" more than once a minute, or you'll wear out the eeprom. It only allows 1 million writes per location -- which isn't a problem unless you try to write to the same location once a milli-second.
Also, I should make it clear that the·recording of the events is something that might happen one or twice a MONTH.··The sequence of events is only going to be changed when the user·gets tired of the old sequence, which may be never!· So I am assuming that wearing out the EEPROM really isn't an issue.· Or am I wrong about this?
As you can see thtis is my first post, and I am very new to the BASIC stamp, and microcontrollers in general.· I just have a neat (I think) idea, and want to play with it.
Thanks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
·
The easiest way to avoid "write fatigue" is to check the contents of an EEPROM location before you WRITE to it and skip the WRITE if the location already contains the desired value. Other things include keeping counters in ordinary (RAM) variables and only writing them to EEPROM when something else changes if that fits with your needs.
Great suggestion about preventing "write fatigue."· i think I'll start playing with this tomorrow.· Anything else you think i should be aware of?
Cheers,
Clinton
·