-
Notifications
You must be signed in to change notification settings - Fork 0
/
LED.py
42 lines (35 loc) · 998 Bytes
/
LED.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
import RPi.GPIO as GPIO
import time
import pyrebase
config = {
"apiKey": "AIzaSyD6cr3TxbHq8WPPVc9vaHfwjp--6FlRIdA",
"authDomain": "cxapi-c8d4d.firebaseapp.com",
"databaseURL": "https://cxapi-c8d4d.firebaseio.com/",
"storageBucket": "cxapi-c8d4d.appspot.com"
}
firebase = pyrebase.initialize_app(config)
db = firebase.database()
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(19,GPIO.OUT)
GPIO.setup(7,GPIO.OUT)
GPIO.setup(11,GPIO.OUT)
GPIO.setup(13,GPIO.OUT)
GPIO.setup(29,GPIO.OUT)
def stream_handler(message):
print(message["data"]) # {'title': 'Pyrebase', "body": "etc..."}
my_stream = db.child("Pi1").child("Pi1").stream(stream_handler)
#my_stream.close()
GPIO.output(19,GPIO.HIGH)
GPIO.output(7,GPIO.HIGH)
GPIO.output(11,GPIO.HIGH)
GPIO.output(13,GPIO.HIGH)
GPIO.output(29,GPIO.HIGH)
time.sleep(1)
#print "LED off"
GPIO.output(19,GPIO.LOW)
GPIO.output(7,GPIO.LOW)
GPIO.output(11,GPIO.LOW)
GPIO.output(13,GPIO.LOW)
GPIO.output(29,GPIO.LOW)
time.sleep(1)