You are on page 1of 4

NAME: G.

AAKANKSHA DATE:
ROLL NO:21EG104A11 PAGE NO:

EXPERIMENT-1
TO INTERFACE LED/BUZZER WITH AURDINO/RASPBERRY PI AND
WRITE A PROGRAM TO TURN ON LED FOR 1 SEC
AFTER EVERY 2 SECONDS

Aim: To interface LED/Buzzer with Aurdino/Raspberry pi and write a program to turn on LED for 1 second
after every 2 seconds.
Apparatus: Raspberry Pi 4,LED,Personal Computer.
Procedure:
1. Connect the Raspberry pi 4 to the Monitor display along with the keyboard, mouse and the ethernet cable.
2. For the LED display connect the 3v3 power supply (pin 1) of the Raspberry pi to the positive terminal of
the LED display board and the negative terminal of the display board to the ground (pin9).
3. Connect the GPIO 18 (pin 12) to one of the LED pin and run the program.
4.Observe the Output.
PROGRAM:
import RPi.GPIO as GPIO // Importing RPi GPIO as GPIO//
import time // Importing or setting time //
GPIO.setwarnings(False) // To get only errors but not warnings //
GPIO.setmode(GPIO.BCM) // Setting the GPIO pin in BCM//
GPIO.setup(18,GPIO.OUT) // Showing output in GPIO18 pin //
while(True): // while loop //
GPIO.output(18,GPIO.HIGH) // Output is high //
time.sleep(1) // Output high only for 1 second //
GPIO.output(18,GPIO.LOW) // Output is low //
time.sleep(2) // Output is low for 2 seconds//

ANURAG UNIVERSITY EMBEDDED SYSTEMS & IOT LAB ECE DEPARTMENT


NAME: G.AAKANKSHA DATE:
ROLL NO:21EG104A11 PAGE NO:

FLOWCHART:
Start

Initialize pin
configuration

Infinity loop

LED ON for 1 sec

LED OFF for 2 seconds

Stop

OUTPUT:

ANURAG UNIVERSITY EMBEDDED SYSTEMS & IOT LAB ECE DEPARTMENT


NAME: G.AAKANKSHA DATE:
ROLL NO:21EG104A11 PAGE NO:

RESULT:
We have performed the experiment to Interface Led/Buzzer with Raspberry Pi and also have written a program
to turn on LED for 1 second after every 2 seconds and observed the output.

ANURAG UNIVERSITY EMBEDDED SYSTEMS & IOT LAB ECE DEPARTMENT


NAME: G.AAKANKSHA DATE:
ROLL NO:21EG104A11 PAGE NO:

INTERFACING DIAGRAM:

LED

Monitor
R
GPIO1
A 8
S
P
B GND
E
R
R
Y

P
I

USB1 USB2

Keyboard Mouse

ANURAG UNIVERSITY EMBEDDED SYSTEMS & IOT LAB ECE DEPARTMENT

You might also like