SHARE
TWEET

MorePi Me v1 Demo #1 Cylon

a guest Mar 17th, 2014 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # MorePi Me v1 Demo by @tymkrs
  2.  
  3. def update():
  4.         for index in range(0, 32):
  5.                 if state[32 - index]:
  6.                         GPIO.output(DataPin, GPIO.HIGH)
  7.                 else:
  8.                         GPIO.output(DataPin, GPIO.LOW)
  9.                 GPIO.output(ClockPin, GPIO.HIGH)
  10.                 GPIO.output(ClockPin, GPIO.LOW)
  11.         GPIO.output(LatchPin, GPIO.HIGH)
  12.         GPIO.output(LatchPin, GPIO.LOW)
  13.  
  14. def clear():
  15.         for index in range(0, 32):
  16.                 state[index] = False
  17.  
  18. state = [False for index in range(33)]
  19.  
  20. LatchPin = 11
  21. ClockPin = 13
  22. DataPin = 15
  23.  
  24. import time
  25. import RPi.GPIO as GPIO
  26.  
  27. GPIO.setwarnings(False)
  28.  
  29. GPIO.setmode(GPIO.BOARD)
  30.  
  31. GPIO.setup(LatchPin, GPIO.OUT) #latch
  32. GPIO.setup(ClockPin, GPIO.OUT) #clock
  33. GPIO.setup(DataPin, GPIO.OUT) #data
  34.  
  35. while True:
  36.         for n in range(0, 8):
  37.                 clear()
  38.                 state[n + 1] = True
  39.                 update()
  40.                 time.sleep(.03)
  41.         for n in range(0, 8):
  42.                 clear()
  43.                 state[8 - n] = True
  44.                 update()
  45.                 time.sleep(.03)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top