Hardware Reference
In-Depth Information
consider storage in terms of bytes. However, as you will see you sometimes want to manipu-
late individual bits in that byte. In the last program you saw that a Boolean variable could
only have one of two possible values; however it takes a byte to store that one variable, so all
the other bits in it are wasted. If you take a byte, you can store the state of eight LEDs in it.
he relationship between the byte, the bits and the LEDs is shown in Figure 11-1.
Figure 11-1:
he relationship
between bits
and bytes.
So by using a byte variable to store the state of all eight LEDs you can then use a list of these
variable to store a sequence of LED patterns. To output each pattern all you have to do is to
write out the next variable in the list to the PiFace board.
Designing the Sequencer
Now that you have all the elements in place you can begin to think about how you want this
to look and operate. his is called top-down design because you start with a top-level view of
what you want the software to look like.
I envisaged a grid of squares, each one representing an LED and its position in the sequence.
A column of eight squares would represent the states of the LEDs at any instance in the
sequence. A marker under the column will indicate what LEDs are being lit at any time. A
mouse click in one of these squares will toggle the LED.
In order to help set up the sequence there should be some control buttons, one to clear or
turn of all the LEDs in all sequence positions, and another to toggle or invert all the LEDs.
here should be control buttons to determine the speed of the sequence and inally one to
select where to take the trigger to advance the sequence from. his last point is important if
Search WWH ::




Custom Search