Flip Flop Help
izulustudios
Posts: 6
Hello and thank you all for this fantastic resource!
I am fumbling around with I suspect is an overly unwieldy amount of code for my application.
My application is as follows:
A set of 8 momentary buttons with an accompanying set of 8 LED's (namely they are illuminated momentary pushbuttons)
I need for each of them to latch; that is, for the corresponding output pin to go high and remain high until any other button is depressed, and for the latch to then shift to the next (random) button to be depressed.
Put very simply: There are 8 buttons, which when pressed, light up and stay lit up until a subsequent button is pressed.
This circuit would be used to control an adjacent system with it's own set of digital inputs and would serve purely as indicator of the last button to have been pressed.
I currently have a convoluted set of IFs, THENs and UNTILs in a big loop, however I suspect there must be a far more elegant way of monitoring a set of 8 dig inputs in one routine and latching a corresponding set of dig outs in another?
Any further guidance would be hugely appreciated.
Thanks again.
Dan
I am fumbling around with I suspect is an overly unwieldy amount of code for my application.
My application is as follows:
A set of 8 momentary buttons with an accompanying set of 8 LED's (namely they are illuminated momentary pushbuttons)
I need for each of them to latch; that is, for the corresponding output pin to go high and remain high until any other button is depressed, and for the latch to then shift to the next (random) button to be depressed.
Put very simply: There are 8 buttons, which when pressed, light up and stay lit up until a subsequent button is pressed.
This circuit would be used to control an adjacent system with it's own set of digital inputs and would serve purely as indicator of the last button to have been pressed.
I currently have a convoluted set of IFs, THENs and UNTILs in a big loop, however I suspect there must be a far more elegant way of monitoring a set of 8 dig inputs in one routine and latching a corresponding set of dig outs in another?
Any further guidance would be hugely appreciated.
Thanks again.
Dan
Comments
People are gonna ask - would you post your code, please? There may be some things to be done there.
Also (my own curiosity), are you sold on using a Stamp for this rather than some latches?
Regards,
DJ
Vaclav
Thanks. Yes, my existing version uses 74LS logic latches, however I am hoping to reduce my component list and use a micro.
This will also allow us to change the conditions later, if needed.
Thanks anyway.
What is the simplest code definition of "set / latch"?.
Thanks again.
Another nice thing about this setup is it lets you see if a button was "released" or "pressed", e.g.
So.... combining the two to latch only a "press"...
I imagined a solution exactly like yours, but was still very hazy with storing the button states as Byte's and the use of OUTS and DIRS.
This really helps me join the dots, so thanks again.