-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIR_LED.py
More file actions
30 lines (23 loc) · 677 Bytes
/
Copy pathIR_LED.py
File metadata and controls
30 lines (23 loc) · 677 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
import serial
import RPi.GPIO as GPIO
import time
ser = serial.Serial('/dev/ttyACM0', 9600)
GPIO.setmode (GPIO.BCM)
GPIO.setwarnings (False)
GPIO.setup (18, GPIO.OUT)
GPIO.setup (15, GPIO.OUT)
GPIO.setup (14, GPIO.OUT)
#ser.write('1')
while True:
room_status = str(ser.readline())
#print(room_status)
if 'z' in room_status:
GPIO.output(18, GPIO.HIGH)
GPIO.output(15, GPIO.HIGH)
GPIO.output(14, GPIO.HIGH)
print ('Lights have been turned on!')
time.sleep(3)
GPIO.output(18, GPIO.LOW)
GPIO.output(15, GPIO.LOW)
GPIO.output(14, GPIO.LOW)
print ('Lights have been turned off!')