-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcontroller.py
More file actions
37 lines (28 loc) · 809 Bytes
/
controller.py
File metadata and controls
37 lines (28 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
import serial
import sys
import time
import pusherclient
DEVICES = ['/dev/tty.usbmodem1411', '/dev/tty.usbmodem1421']
def new_active_call(data):
print 'new_active_call'
arduino.write('a')
def connection_established(data):
print 'connection_established'
channel = pusher.subscribe('active-calls')
channel.bind('new_active_call', new_active_call)
arduino = None
for device in DEVICES:
try:
arduino = serial.Serial(device, 9600)
print 'Connected to device %s' % device
break
except:
continue
else:
print 'Could not connect to Arduino!'
sys.exit()
pusher = pusherclient.Pusher('d20fddb74c58823cd05d')
pusher.connection.bind('pusher:connection_established', connection_established)
while True:
time.sleep(1)