Writing our Python program
To start with, we will write a simple, short piece of Python just to check that all ten of our LEDs are working, and we know which GPIO pin controls which pair of LEDs. Power on your Pi Zero and connect to it via SSH.
Testing our LEDs
To check that our LEDs are all correctly wired up and that we can control them using Python, we will write this short program to test them.
First, move into our project directory by typing this:
cd ~/WearableTech/
Now, make a new directory for this chapter by typing this:
mkdir Chapter3
Now, move into our new directory:
cd Chapter3
Next, we create our test program by typing this:
nano testLED.py
Then, we enter the following code into Nano:
#!/usr/bin/python3 from gpiozero import LED from time import sleep pair1 = LED(11) pair2 = LED(9) pair3 = LED(10) pair4 = LED(7) pair5 = LED(8) for i in range(4): pair1.on() sleep(2) pair1.off() pair2.on() sleep(2) pair2.off() pair3.on() sleep(2) pair3.off() ...