I have been experimenting with tut06 that came with sample Flow Code.
How do I generate a Flow code so that I can create a D type Flip Flop circuit i.e when a switch has momentarily made contact on Port A Ra0 for example, how can the Led on Port B rb0 be made to remain lit instead of going out when the input switch has been released and so that when a switch on port A on Ra1 is made momentarily, the LED on Rb0 goes out and then another LED on Port B rb1 comes on and stays on when switch Ra1 released.
Hope this makes sense
Flip-Flop
- Steve
- Matrix Staff
- Posts: 3433
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
I suggest you use a variable, STATE, to define which state the outputs should be (i.e. should RB0 be on or should RB1 be on). You could then react to changes in the input and set this state appropriately.
If you want to be neater, your STATE variable could flip between 1 and 2 as these values (when output to port b) will give you the required values of B0 and B1.
Here'a a pseudocode example:
If you want to be neater, your STATE variable could flip between 1 and 2 as these values (when output to port b) will give you the required values of B0 and B1.
Here'a a pseudocode example:
Code: Select all
STATE = 1
loop forever
if (STATE = 1)
if (RA1 = on)
STATE = 2
end if
else
if (RA0 = on)
STATE = 1
end if
end if
output STATE to port b (with masking, so only b0 and b1 are affected)
end loop