A friend of ours called and asked my wife, Debbie, if we had a Raspberry Pi and knew how to use it. Her son had a project due for school and needed to control about 20 LEDs - sequencing when they were on and off. I had all of the hardware because I had played around with an Arduino and had bought some electronics parts that would be needed - breadboard, LEDs, resistors, and wires. I had also purchased a Pi Cobbler Plus Breakout board to simplify connecting the Pi. The only thing I had really done with the Pi to this point was copying the Raspian OS to an microSD memory card and booting the Pi. Time for me to learn some Python and put the Pi to work.
I had never written any code in Python, so I went to the web to find some examples. A friend from work had also sent me an e-mail with a couple of short routines to turn an LED on and off. The project was to have a map of Europe and indicate different areas where battles were occuring during World War I. The goal was to have the display to remain lit for an amount of time to indicate the duration of the battle. I was able to spend a few minutes and came up with the following code:
The map was going to displayed on a standing kiosk and needed to run unattended. I setup the Pi so that this Python app automatically ran once the Pi was turned on. Although my friend’s son never saw this code, it was a fun exercise for me to utilize the Pi and learn some Python in the process.