Wednesday, December 16, 2015

Project 2 : Blinking LED Using IR Proximity Sensor and Raspberry Pi

Objective: In this project you will be able to control the LED light by infrared proximity sensor. If there is an object in proximity of the sensor, then the LED will be ON otherwise it will be OFF.

Material Required:

  • Raspberry Pi
  • LED light
  • 1k ohm resistance
  • Jumper wires
  • Bread board
  • Infrared Proximity Sensor
Circuit Diagram:


Program:

import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO_IN=6
GPIO.setmode(GPIO.BOARD)
GPIO.setup(GPIO_IN,GPIO.IN)

while True:
         status=GPIO.input(GPIO_IN)
         if status == 1:
            GPIO.output(5,1)
            time.sleep(2)
         else:
            GPIO.output(5,0)
            time.sleep(2)

Project 1: Simple LED Blink Using Raspberry Pi

Objective: This is simple Raspberry Pi project to blink LED. When you execute this program with required setup then you will see that the the LED is blinking ON and OFF for one second.

Material Required:
  • Raspberry Pi
  • LED Light
  • 1k ohm Resistance
  • Jumper Wires
  • Bread Board
Circuit Diagram:

Raspberry Pi
Python Program:
import RPi.GPIO as GPIO
import time
GPIO_OUT=5
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(GPIO_OUT,GPIO.OUT)
while True:
        GPIO.output(GPIO_OUT,1)
        time.sleep(1)
        GPIO.output(GPIO_OUT,0)
        time.sleep(1)