Exemple #1
0
from arduino import Arduino
import time

b = Arduino("/dev/tty.usbmodem1421")
pin = 13

# declare output pins as a list/tuple
b.output([pin, 13])
b.input([8])
b.servos([])

# for i in xrange(18):
#     # b.setHigh(pin)
#     # time.sleep(1)
#     # print b.getState(pin)
#     # b.setLow(pin)
#     # print b.getState(pin)
#     # time.sleep(1)
#     an = 3.14/180 * i * 10
#     an = i*10
#     print an
#     b.setAngle(12,an)

# time.sleep(1)
pos = 1
d = 1
s = 20
while 1:
    button = b.digitalRead(8)

    # if (button!=u'0\r'):
Exemple #2
0
import time

try:
    b = Arduino('/dev/tty.usbmodem1421')
    print "Connected to usbmodem1421"
except:
    try:
    	b = Arduino('/dev/ttyACM0')
	print "Connected to ttyACM0"
    except:
        b = Arduino('/dev/ttyUSB0')
	print "Connected to ttyUSB0"

led_pin = 13
b.output([led_pin])
b.input([])
b.servos([])   
print "Pin setup done"

for i in xrange(18):
    b.setHigh(led_pin)
    time.sleep(1)
    print b.getState(led_pin)
    b.setLow(led_pin)
    print b.getState(led_pin)
    time.sleep(1)



#servo1 = 13
#servo2 = 12