Skip to content

Instantly share code, notes, and snippets.

@gbrennon
Last active August 29, 2015 14:06
Show Gist options
  • Save gbrennon/35af49e7b5dfb3bc9623 to your computer and use it in GitHub Desktop.
Save gbrennon/35af49e7b5dfb3bc9623 to your computer and use it in GitHub Desktop.
import thread
import time
import random
import RPi.GPIO as GPIO
def blinkTask(pin):
state = False
pin = int(pin)
while 1:
state = not state
freq = random.uniform(0.1, 0.7)
print "Blinking %s at %s" % ( pin, freq)
time.sleep(freq)
GPIO.output(pin, state)
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(7, GPIO.OUT)
GPIO.setup(5, GPIO.OUT)
try:
thread.start_new_thread( blinkTask, (7,) )
thread.start_new_thread( blinkTask, (5,) )
except:
print "Error: unable to start thread"
while 1:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment