0% found this document useful (0 votes)
134 views3 pages

3 RPI Feedback From Switch

This document describes an experiment using a Raspberry Pi to take feedback from switches connected to LEDs. The circuit diagram shows a Raspberry Pi connected to two LEDs and two push button switches through resistors. The procedure explains how to connect the components and run a Python program. The program uses GPIO pins to detect when a switch is pressed, turning on the corresponding LED, and released, turning off the LED. This provides feedback to the user on the switch state.

Uploaded by

satyam jadhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
134 views3 pages

3 RPI Feedback From Switch

This document describes an experiment using a Raspberry Pi to take feedback from switches connected to LEDs. The circuit diagram shows a Raspberry Pi connected to two LEDs and two push button switches through resistors. The procedure explains how to connect the components and run a Python program. The program uses GPIO pins to detect when a switch is pressed, turning on the corresponding LED, and released, turning off the LED. This provides feedback to the user on the switch state.

Uploaded by

satyam jadhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

RASPBERRY Pi – STUDY OF FEEDBACK FROM SWITCH

STUDY OF RASPBERRY Pi FEEDBACK FROM SWITCH


AIM: Programming of Raspberry Pi to take feedback from the switch

APPARATUS: Raspberry Pi with Raspbian Pi OS, LEDs, Resistors, Push button switch, USB
Keyboard, mouse LCD Monitor, HDMI to VGA converter, 5V Power Adapter.

CIRCUIT DIAGRAM:

1kΩ
1

RASPBERRY Pi
3B + 1kΩ
10

39

Procedure:

1. The kit consists of Raspberry Pi 3B+, Power adapter, HDMI to VGA converter cable and
PCB with LEDs connected and the 9 pin connector.
2. One two pin and other five pin male connectors are available on the PCB.
3. The two pin connector is of 3.3V and other five pin connector consists of male connector
in the sequence of Ground, LED1, LED 2, SW1 and SW2.
4. Two LEDs and Two switches are available. You can use one pair of LED and a switch ot
both LEDs and two switches.
5. Connect the circuit as shown in the circuit above. Use Female to Female connecting
wires to connect Raspberry Pi pins to the Led pins and switch, available on the PCB.
6. Run the program using “run” button in the IDE, it will ask you to save the file. If not
saved before, save it with file name extension .py
RASPBERRY Pi – STUDY OF FEEDBACK FROM SWITCH

7. Now press the switch (SW1), you will observe LED is glowing. After releasing the
switch, the LED turns off. Press second switch (SW2), you will observe other LED is
glowing and turns off after releasing the SW2.

Program 1:

# PROGRAM TO TAKE FEEDBACK FROM THE SWITCH


import RPi.GPIO as GPIO # Import GPIO Library
import time # Import Time Library
GPIO.setmode(GPIO.BOARD) # Set the pins as the pin numbers
GPIO.setup(8,GPIO.IN) # Set pin 8 as input
GPIO.setup(10,GPIO.OUT) # Set pin 10 as output
GPIO.output(10, False) #Turn LED OFF
while(True):
x = GPIO.input (8) # Name the pin 8 as “x”
#single pressed
If (x==0): # Check logically if the key is pushed
GPIO.output (10, True) # Make output pin 10 HIGH, Turn ON LED
print ("Switch Pressed") #Print Switch is pressed
else:
GPIO.output (10, False) # Make output pin 10 LOW, Turn OFF LED
print ("Switch Released") #Print Switch is released

Program 2:
RASPBERRY Pi – STUDY OF FEEDBACK FROM SWITCH

You might also like