This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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