Hardware Reference
In-Depth Information
Run the program and see what it does. Remember that on the Raspberry Pi you
have  to  run this program from within a LXTerminal window with
sudo python testDisplay.py .
CHALLENGE
Try to work out the values to put into the pattern list for each of the digits 0 to 9.
Remember that the True / False values in the pattern list are ordered
A,B,C,D,E,F,G,DP—test them on your display. How many different letters of the
alphabet can you design for your 7-segment display? You can find some useful
examples of 7-segment patterns at this Wikipedia page: http://en.wikipedia.org/
wiki/Seven-segment_display
Using a Python Module to
Control.the.Display
You might have discovered that there are many different useful patterns that you can
display to a 7-segment display. To make it easier to use all of these patterns, I have
written a small Python module called seg7.py , which is included in the starter kit in
the anyio folder. You can use and modify this module as much as you like and add it
to your own games and programs. By following these steps you will see that it is very
easy to link it into an existing program:
1. Start a new program by clicking File New File and save it as testDisplay2.py .
2. Import my display module, and also the time module so you can add delays.
import anyio.seg7 as display
import time
3. Copy in every line from your testDisplay.py from the start, up to and
including the ON=False line.
4. After this, set up the display module by giving it access to your GPIO pins and
giving it a list of the pin numbers to use for each of the segments:
display.setup(GPIO, LED_PINS, ON)
5. Write a game loop that counts repeatedly from 0 to 9. The reason we have done
this as a loop is so that you can leave the loop running indefinitely and wiggle
the wires around if some of the segments don't seem to work, without having to
keep re-running your program.
 
 
Search WWH ::




Custom Search