forked from TinajaLabs/gateway_raspi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testLED.py
43 lines (31 loc) · 886 Bytes
/
testLED.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
import serial
from xbee import XBee
import time
SERIALPORT = "/dev/tts/0"
BAUDRATE = 9600
serial_port = serial.Serial(SERIALPORT,BAUDRATE)
xbee = XBee(serial_port)
thisDest = '\x00\x0f'
xbee.send('remote_at',
frame_id='C',
dest_addr=thisDest,
options='\x02',
command='IR',
parameter='\x32')
print xbee.wait_read_frame()['status']
# Deactivate LED pin, D4
xbee.remote_at(dest_addr=thisDest,command='D4',parameter='\x04')
xbee.remote_at(dest_addr=thisDest,command='WR')
led=False
while 1:
#set led status
led=not led
if led:
xbee.remote_at(dest_addr=thisDest,command='D4',parameter='\x04')
print "LED Off"
else:
xbee.remote_at(dest_addr=thisDest,command='D4',parameter='\x05')
print "LED On"
# wait 1 second
time.sleep(1)
serial_port.close()