Learn Steps

How to blink LED lights using raspberry pi

Hello everyone we are back with another article on how to blink LED lights using Raspberry pi. This will be a short tutorial follow the steps and you will be able to get a LED blink as you instruct it.

 

How to blink LED lights using raspberry pi

How to Blink LED lights using raspberry pi

What you need:

Raspberry PI

LED

100 ohm Register

Breadboard for better management.

Connect as instructed below:

Insert the LED in Breadboard. Connect one end of led to the register.

Now connect the other end to the GND on GPIO pins in Raspberry PI.

Next you need to do is connect other end of register which is not connected to LED to any pin Lets connect it to pin 13 i.e. GPIO 13

Now you connection is complete. We need register to stay safe of abrupt current flow.

Next what you need to do is to write a simple code in python which can do the rest.

Python is a common  purpose programming language and you don’t need to know a lot for this tutorial. Just copy paste the code and run it and it will work.

 

What you need to do after connecting the circuit. 

Copy the code below and save in file named blink.py.

Open Terminal now run the file by using

sudo python blink.py.

Now lets look at the code. 

First we import the important required libraries.

GPio is used for accessing GPIO ports and working with them. Time is used for using sleep function.

Next we number the port of LEDPin = 13 and times we need to blink the LED as blink_count = 7. 

Here we will blink the LED 7 times.

Next we setup the pin 13 of board as output pin thus it will send current when true.

Now we started a loop which will run until blink_count is less than 7.

In next line we send true to output pin which will turn on the LED and keep it for one second after which we send false to the pin.

Thus it blinked. In the same fashion it will blink for 7 times and then it stops.

Liked the article follow for more such interesting articles. Also read

Raspberry PI Motion sensor Example