Advertisement
Guest User

Untitled

a guest
May 4th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. # Import the required module.
  2. import RPi.GPIO as GPIO
  3. # Set the mode of numbering the pins.
  4. GPIO.setmode(GPIO.BCM)
  5. #GPIO pin 10 is the output.
  6. GPIO.setup(13, GPIO.OUT)
  7. #GPIO pin 8 is the input.
  8. GPIO.setup(6, GPIO.IN)
  9. #Initialise GPIO13 to low (False) so that the LED is on.
  10. GPIO.output(13, False)
  11. while 1:
  12. if GPIO.input(6):
  13. GPIO.output( 13, True)
  14. else:
  15. GPIO.output( 13, False)
  16. #keep LED on till the button pressed again then it turns off?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement