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

.

Then Type Ctrl X and Yes to save the file. and press enter

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 http://osoyoo.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:

Posted in Raspberry Pi Project

Leave a Reply

WordPress spam blocked by CleanTalk.

Meta