Raspberry Pi: Blinking LED

So this is my first project with Raspberry Pi! I’ve made a simple blinking LED project.

Check out other Raspberry Pi Projects here: (LINK)

Demo:

Things Required:

  1. Raspberry Pi (I’ve used Raspberry Pi 3)
  2. Keyboard
  3. Mouse
  4. HDMI Screen
  5. LED
  6. 1 k ohm resistor

Reference Material:

  1. Getting started with python and raspberry pi: (LINK)
  2. For the project: (LINK)

Code:

Note that the following code is in python!

View on/Download from Github: (LINK)

#!/usr/bin/python3
import RPi.GPIO as  GPIO
import time 

ledpin=22

def setup():
   GPIO.setmode(GPIO.BOARD)
   GPIO.setup(ledpin, GPIO.OUT)
   GPIO.output(ledpin, GPIO.LOW)


def loop():
   while True:
     print ('LED on')
     GPIO.output(ledpin, GPIO.HIGH)
     time.sleep(1.0)
     print ('LED off')
     GPIO.output(ledpin, GPIO.LOW)
     time.sleep(1.0)


def endprogram():
   GPIO.output(ledpin, GPIO.LOW)
   GPIO.cleanup()

if __name__ =='__main__':
   setup()
   try:
     loop()
   except KeyboardInterrupt:
     endprogram()

Stay Tuned for upcoming posts on Raspberry Pi Projects! Want to be the first to know when a new and amazing post comes up?? Then feel free to subscribe!

Happy Learning!!

This image has an empty alt attribute; its file name is stay-tuned.gif

Leave a Reply

PHP JS HTML CSS BASH PYTHON CODE

Your email address will not be published.

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

%d bloggers like this: