forked from jewelia/txtduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
txtduino.py
49 lines (37 loc) · 1.11 KB
/
txtduino.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
45
46
47
48
49
import settings
import sys
from BreakfastSerial import Led, Arduino, Button
from twilio import TwilioRestException
from twilio.rest import TwilioRestClient
board = Arduino()
LED_PIN = 13
BUTTON_PIN = 2
led = Led(board, LED_PIN)
button = Button(board, BUTTON_PIN)
msg_sent = False
def down_press():
global msg_sent
print "button down"
if not msg_sent:
# Turn on the LED to indicate we are sending the txt message!
led.on()
try:
client = TwilioRestClient(settings.twilio_account_sid,
settings.twilio_auth_token)
message = client.sms.messages.create(
body="Hello from Julia's rad Arduino!",
to=settings.your_phone_number,
from_=settings.your_twilio_number)
except TwilioRestException as e:
print "Ruh-roh got an error: %s" % e
led.off()
sys.exit(0)
print "Attempting to send message, status is: %s" % message.status
msg_sent = True
led.off()
def up_press():
print "button up"
button.down(down_press)
button.up(up_press)
while(not msg_sent):
continue