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

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

 

 


Gaurav Yadav

Gaurav is cloud infrastructure engineer and a full stack web developer and blogger. Sportsperson by heart and loves football. Scale is something he loves to work for and always keen to learn new tech. Experienced with CI/CD, distributed cloud infrastructure, build systems and lot of SRE Stuff.

2 COMMENTS
  • #python Learn how to blink led lights using raspberry pi. Simple tutorials get the code follow and you are done. Its as simple by using python programming language… – DevOps Infographics Resource Center – Programming and IT
    Reply

    […] We are want to say thanks if you like to share this post to another people via your Facebook, Pinterest, Google Plus or Twitter account. To save infographic right click on this or tab and hold for seven seconds if you are using iPad or iPhone. Full size is 736X454 Link to full-size image pixels. The source of this magnificent image from learnsteps.com […]

  • #python Learn how to blink led lights using raspberry pi. Simple tutorials get the code follow and you are done. Its as simple by using python programming language… – DevOps Infographics Resource Center – Programming and IT
    Reply

    […] We are want to say thanks if you like to share this post to another people via your Facebook, Pinterest, Google Plus or Twitter account. To save infographic right click on this or tab and hold for seven seconds if you are using iPad or iPhone. Full size is 736X454 Link to full-size image pixels. The source of this magnificent image from learnsteps.com […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.