Advertisement
KRITSADA

RaspberryPi #1 Control LED with Command From Terminal

Jan 11th, 2017
6,167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import RPi.GPIO as GPIO
  2. import time
  3. GPIO.setwarnings(False)
  4. GPIO.setmode(GPIO.BCM)
  5. GPIO.setup(25, GPIO.OUT)
  6. GPIO.setup(26, GPIO.OUT)
  7. GPIO.setup(27, GPIO.OUT)
  8. while 1:
  9.     a=input("Please Input String ")
  10.     if a=="ON 1":
  11.         GPIO.output(25,1)
  12.     if a=="ON 2":
  13.         GPIO.output(26,1)
  14.     if a=="ON 3":
  15.         GPIO.output(27,1)
  16.     if a=="OFF 1":
  17.         GPIO.output(25,0)
  18.     if a=="OFF 2":
  19.         GPIO.output(26,0)
  20.     if a=="OFF 3":
  21.         GPIO.output(27,0)
  22.     if a=="ALL OFF":
  23.         GPIO.output(25,0)
  24.         GPIO.output(27,0)
  25.         GPIO.output(26,0)
  26.     if a=="ALL ON":
  27.         GPIO.output(25,1)
  28.         GPIO.output(27,1)
  29.         GPIO.output(26,1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement