Output signal from Raspberry Pi GPIO pin to LED

Byadmin

Output signal from Raspberry Pi GPIO pin to LED


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 raspi
1 pc 8GB MicroSD memory card preinstalled Raspbian OS. 8gtf
1 pc LED Red_LED
1 pc 220 Ω resistance 220_resistor
1 pc breadboard BREADBOARD
1 pc GPIO breakout kit(optional) breakout

Prerequisite:

1)Raspbian should be upgraded to latest version in order to support RPI.GPIO module
Please run following commands in shell:

  • sudo apt-get update
  • sudo apt-get upgrade

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:
giotest

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:

About the Author

admin administrator

You must be logged in to post a comment