Skip to content

Instantly share code, notes, and snippets.

Created February 11, 2013 04:34
Show Gist options
  • Save anonymous/4752636 to your computer and use it in GitHub Desktop.
Save anonymous/4752636 to your computer and use it in GitHub Desktop.
import pyfirmata
print "maker1"
# Create a new board, specifying serial port
board = pyfirmata.Arduino('/dev/ttyACM0')
print "maker2"
# start an iterator thread so that serial buffer doesn't overflow
it = pyfirmata.util.Iterator(board)
it.start()
print "maker3"
# set up pins
pin0=board.get_pin('a:0:i') # A0 Input (LM35)
pin3=board.get_pin('d:3:p') # D3 PWM Output (LED)
print "maker4"
# IMPORTANT! discard first reads until A0 gets something valid
while pin0.read() is None:
pass
print "maker5"
while True :
print "PWM: " + str( pin0.read() )
board.pass_time(1) # pause 1 second
print "maker6"
board.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment