Objective:
In this project, we will use GPIO port 21 (Pin 40) to output signals to LED and make it flashing ten times.
If you don’t know what is GPIO layout, check our tutorial How to read Raspberry Pi i/o pin diagram (GPIO pin graph)
Parts:
1 pc | Raspberry Pi 2/3/zero | ![]() |
1 pc | 8GB MicroSD memory card preinstalled Raspbian OS. | ![]() |
1 pc | LED | ![]() |
1 pc | 220 Ω resistance | ![]() |
1 pc | breadboard | ![]() |
1 pc | GPIO breakout kit(optional) | ![]() |
Prerequisite:
1)Raspbian should be upgraded to latest version in order to support RPI.GPIO module
Please run following commands in shell:
2)Enable I2C and SPI protocol
To enable the protocol, run shell command
sudo raspi-config
Then select Advance Options and enable I2C and SPI
You need to reboot to effect the configuration
Assemble Circuit as per following graph:
Write python code
Run following command in shell window:
sudo nano testgpio.py
then copy python code and paste the code into testgpio.py
If you don’t want use nano to write code, You can also download above python file from our server by typing following shell command:
sudo wget –no-check-certificate http://kookye.com/wp-content/uploads/samplecode/testgpio.py
Finally, run following command in shell window:
sudo python testgpio.py
You will see the LED flashing 10 times and then the python program stops automatically
Project Video:
You must be logged in to post a comment
About the Author