Created
August 23, 2011 10:05
-
-
Save fermuch/1164776 to your computer and use it in GitHub Desktop.
Arduino Test
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
# -*- coding: utf-8 -*- | |
import sys | |
import time | |
from commands import getoutput | |
from arduino import Arduino | |
out = getoutput("ls /dev/ | grep -i ttyUSB").split() | |
try: | |
out[0] | |
print "Utilizando dispositivo: %s" % (out[0]) | |
boardDev = out[0] | |
except IndexError: | |
print "No se pudo encontrar ningún dispositivo utilizable" | |
sys.exit() | |
board = Arduino(boardDev) | |
pin = 11 | |
i = 0 | |
ilimit = 100 # total de impresiones necesarias | |
try: | |
#while(True): | |
while(i<ilimit): | |
print board.analogRead(pin) | |
time.sleep(1) | |
i+=1 | |
if (i == ilimit): | |
Arduino.close() | |
except KeyboardInterrupt: | |
Arduino.close() | |
sys.exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment