Guest User

Untitled

a guest
Jun 25th, 2018
1,115
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #import Pi GPIO and time modules
  2. import RPi.GPIO as GPIO
  3. import time
  4.  
  5. #set up GPIO numbering and turn off warnings (don't worry if you don't understand this right now)
  6. GPIO.setmode(GPIO.BOARD)
  7. GPIO.setwarnings(False)
  8.  
  9. #set up which pin to control the LED from and set it to output
  10. ledPin = 12
  11. GPIO.setup(ledPin, GPIO.OUT)
  12.  
  13. """
  14. This for loop runs the code inside it 5 times, change the number in the range() brackets to alter how many times it runs.
  15. The LED turns on for half a second, then turns off again.
  16. Make sure you indent the code inside the for loop correctly!
  17. """
  18.  
  19. for i in range(5):
  20.     print("LED turning on")
  21.     GPIO.output(ledPin,GPIO.HIGH)
  22.     time.sleep(0.5)
  23.     print("LED turning off")
  24.     GPIO.output(ledPin,GPIO.LOW)
  25.     time.sleep(0.5)
RAW Paste Data