Quote:
Originally Posted by smcmahon
What's the proper way to program the Spike relays to accomplish what I described above?
|
I can think of three "proper" ways to do it. One is conceptually simple but has nested case statements that are hard to read at a glance. One is elegant but unobvious, using boolean arrays to derive a single number that selects from four cases. My favorite isn't exactly pretty, but it's small and easy to explain.
Place two
Select functions (you'll find them in the
Comparison palette). Wire button 1 to the
s input (labeled with a question mark) of the first one. The
f (bottom) input should have a relay "
Off" constant, and the
t (top) input should have a relay "
Forward". The second
Select's
s input should be wired from button 2, the
f input from the output of the first
Select, and the the
t input should have a relay "
Reverse". The output of the second
Select goes to the input of a
Relay Set.
When neither button is pressed, the
Off is selected through to the relay. When button 1 is pressed (and button 2 is not), the relay sees the
Forward. When button 2 is pressed, the relay is set
Reverse.
Does that make sense?