Hardware Reference
In-Depth Information
Now remove the power and touch the two negative wires again just to discharge the power
supply before wiring it up to the PiFace board. Then attach the PiFace board to the Raspberry
Pi and boot it up, plug in the 12V power supply and run the software. A note of caution:
Never connect anything to the Raspberry Pi when it is powered up; it is easy to have an acci-
dent, and you can damage things with incomplete or partial wiring.
Using Longer Strip Lights
Now what about the longer strip light I mentioned at the start of the last section? You can
draw up to 450mA from each of the outputs from the PiFace board so you can have longer
strips of LEDs. This amount of current will drive 66 LEDs or 22 groups of three - this is
a  strip of 0.7 meters long. However, the down side is that you can't have more than one
LED strip lit at any one time. With the existing software it is too easy to make a mistake and
set two or more LEDs to come on in each column, but with the changing of just one line in
the code you can make the software act as a safety watch dog and only allow one strip light to
be on at any one time. The line is in the mouseGet function six lines in, and it is one that has
been discussed already:
seq[byte] ^= 1 << bit
Now take that line and change it to
seq[byte] = (seq[byte] & (1 << bit) ) ^ (1 << bit)
You might also want to change the title of the window and the colour scheme at the start so
you can distinguish between the two programs. Also, save it under a different name. What
this line now does is clear out the sequence value for all bits except the bit you have clicked,
and then it toggles that bit. So if any other bit has been set in that step it is cleared and the
bit you have clicked is toggled. This prevents you from setting more than one strip to be lit at
any one time. However, there is still a slight danger because if you click the invert control, all
the outputs but one will be on. To be on the safe side you should remove the following line
(10 lines down from the one you just changed):
seq[a] ^= 0xff
To tidy up the screen display you should remove the call to drawControl that sets up the
invert control in the setupScreen function. You don't have to buy a strip 0.7 meter long; if
you want you can join strips together if you cannot buy them in the length you want.
Search WWH ::




Custom Search