Newbie - How to program a certain sequence
tbsmith
Posts: 3
Hi, I am trying to program a BS1 (or can get a BS2, if necessary) to do the following:
On power up, activate ouptut 1
When button 1 is pressed, turn off ouput 1.
When button 1 is released, turn on output 2
When button 1 is pressed again, turn off ouput 2
When button 1 is released, turn on output 3
...and so on for all the outputs.
When the last output is turned off, go back to the beginning and start over with output 1.
I may need to do this for up to 40 outputs and read somewhere that a shift register might work with the PWM command, to get that many ouputs (or maybe I will wire the ouputs in a matrix fashion) but I need to walk before running, so maybe you could help with the first part at least.
Thanks!
Tom
On power up, activate ouptut 1
When button 1 is pressed, turn off ouput 1.
When button 1 is released, turn on output 2
When button 1 is pressed again, turn off ouput 2
When button 1 is released, turn on output 3
...and so on for all the outputs.
When the last output is turned off, go back to the beginning and start over with output 1.
I may need to do this for up to 40 outputs and read somewhere that a shift register might work with the PWM command, to get that many ouputs (or maybe I will wire the ouputs in a matrix fashion) but I need to walk before running, so maybe you could help with the first part at least.
Thanks!
Tom
Comments
How about researching the commands DIRS, OUT, and IN?
Thanks,
Tom
The xor "^" will turn on only the bits set in the array byte and turn all others off
You only have to keep track of the index. You will have to do some more if then logic for the 2 banks of pins on the BS2 1-7 and 8-15
You have a BS1? In that case, you have 8 pins total and not as many fancy commands as the BS2. It is still possible. Something like this will move the high output around the circle of 7 pins slowly in the pattern you want, maybe: (Sorry, my BS1 syntax rules are kind of rusty)
To make it happen in response to a button instead of pauses, you need to replace the pauses with something like this:
Expansion to more outputs with shift registers will be more work, but the logic should be about the same.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Tom