Advertisement
Guest User

Untitled

a guest
Jan 16th, 2014
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. import RPi.GPIO as GPIO
  3. import time
  4. GPIO.setmode(GPIO.BOARD)
  5. GPIO.setup(7, GPIO.OUT)
  6. GPIO.setup(16, GPIO.OUT)
  7. GPIO.setup(22, GPIO.OUT)
  8. def Blink(numTimes,speed):
  9.     for i in range(0,numTimes):
  10.     print "Iteration " + str(i+1)
  11.     GPIO.output(7,True)
  12.     GPIO.output(22,False)
  13.     GPIO.output(16,False)
  14.     time.sleep(speed)
  15.     GPIO.output(7,False)
  16.     GPIO.output(22,True)
  17.     GPIO.output(16,False)
  18.     time.sleep(speed)
  19.     GPIO.output(7,False)
  20.     GPIO.output(22,False)
  21.     GPIO.output(16,True)
  22.     time.sleep(speed)
  23.     GPIO.output(7,False)
  24.     GPIO.output(22,False)
  25.     GPIO.output(16,False)
  26.     print "Done"
  27.     GPIO.cleanup()
  28. iterations = raw_input("Enter total number of times to blink: ")
  29. speed = raw_input("Enter length of each blink(seconds): ")
  30. Blink(int(iterations),float(speed))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement