-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtweetCode.py
44 lines (41 loc) · 990 Bytes
/
tweetCode.py
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
38
39
40
41
42
43
44
import serial
import subprocess
import time
ser = serial.Serial(
port='/dev/ttyACM0',\
baudrate=9600,\
timeout=0)
print("connected to: " + ser.portstr)
thirsty = 'Give me Water Feeling Thirsty '
happy = 'Got Water Happy '
#this will store the line
line = []
lastmsg = ""
while True:
ser.flushInput()
for c in ser.read():
if c=='2':
msg = thirsty
print msg
if msg == lastmsg:
print "Duplicate"
time.sleep(5)
else:
#command='twitter -e [email protected] set %s' % msg
command = 'fbcmd post "%s"'%msg
lastmsg = msg
subprocess.call(command, shell=True)
elif c=='1':
msg = happy
print msg
if msg == lastmsg:
print "Duplicate"
time.sleep(5)
else:
#command='twitter -e [email protected] set %s' % msg
command = 'fbcmd post "%s"'%msg
lastmsg = msg
subprocess.call(command, shell=True)
#print(''.join(line))
break
ser.close()