-
Notifications
You must be signed in to change notification settings - Fork 3
/
blinkBuzz.py
58 lines (42 loc) · 1.22 KB
/
blinkBuzz.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
50
51
52
53
54
55
56
from pybleno import *
import sys
import signal
import threading
import time
import RPi.GPIO as GPIO
def alarm(delay, count):
def onStateChange(state):
print('on -> stateChange: ' + state);
if (state == 'poweredOn'):
bleno.startAdvertisingIBeacon('e2c56db5dffb48d2b060d0f5a71096e0',1,2,-60)
else:
bleno.stopAdvertising()
GPIO.setmode(GPIO.BCM) # Set GPIO Pin As Numbering
GPIO.setwarnings(False)
GPIO.setup(17, GPIO.OUT) # for Buzzer
GPIO.setwarnings(False)
GPIO.setup(22,GPIO.OUT)# for LED
if delay ==1 and count ==3:
bleno = Bleno()
bleno.on('stateChange', onStateChange)
for i in range(0,count):
beep(delay)
blink(delay)
if delay ==1 and count ==3:
bleno.stopAdvertising()
bleno.disconnect()
print('disconnected')
def beep(x):
GPIO.output(17, GPIO.HIGH)
time.sleep(x)
GPIO.output(17, GPIO.LOW)
time.sleep(0.2)
def destroy():
GPIO.cleanup()
def blink(x):
GPIO.output(22,GPIO.HIGH)
time.sleep(x)
GPIO.output(22,GPIO.LOW)
time.sleep(x)
#t1 = threading.Thread(target=alarm, args=(0.2,2,))
#t1.start()