Introduction

In this article, I am going to explain about making LED high and low, using push-button In Raspberry Pi. It will operate with one push button, which acts as high and another push button, which can act as low.
Parts Of Lists
Parts Explanation
In the article, I have already explained about Raspberry Pi, LED, Bread Board, Resistor. Now, I am going to explain about the push button and its uses.
Push-button
 Push Button
Uses
Let's Start Connecting the Parts with the RPI
Programming Part
  1. import RPi.GPIO as GPIO
  2. import time
  3. GPIO.setmode(GPIO.BCM)
  4. GPIO.setup(13, GPIO.OUT)
  5. GPIO.setup(11, GPIO.IN, pull_up_down = GPIO.PUD_UP)
  6. GPIO.setup(12, GPIO.IN, pull_up_down = GPIO.PUD_up)
  7. while True:
  8. input_state = GPIO.input(11)
  9. GPIO.output(13, 0)## Turn ON HIGH
  10. if input_state == True:
  11. input_state = GPIO.OUTUT(12)
  12. GPIO.Output(13, 0)## Turn ON LOW
  13. if input_state == False:
  14. print('Button Pressed')
  15. time.sleep(0.2)
Programming Explanation
In this program, I have simply explained about the brightness and dimness of the LED. It will operate when the First push button is pressed, it will be on the high and when the second Push button is pressed, it will be on the low.
  1. input_state = GPIO.input(11)
  2. GPIO.output(13, 0)## Turn ON HIGH
  3. if input_state == True:
  4. input_state = GPIO.OUTUT(12)
  5. GPIO.Output(13, 0)## Turn ON LOW
  6. if input_state == False:
According to the connection, it will be high or low.
Output
button