Code: Select all
#!/usr/bin/python
import bluetooth
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
RELAY = 17
GPIO.setup(RELAY, GPIO.OUT)
while True:
print "Checking " + time.strftime("%a, %d %b %Y %H:%M:%S",
time.gmtime())
result = bluetooth.lookup_name('78:7F:70:38:51:1B', timeout=5)
if (result != None):
print "User present"
GPIO.output(RELAY,1)
else:
print "User out of range"
GPIO.output(RELAY,0)
time.sleep(10)
Hello world i find this code on internet github and i its working fine the led is turn on when you have bluetooth on and the led is turn off when bluetooth is off
this project i want to instal in my car i have a switch for lock and unlock the doors : the problem is i have to give signal for 1 or 2 sec ( pin 17 led stay on for 2 sec when bluetooth is on) and (pin 18 led stay on for 2 sec when bluetooth is off , of course i have to put another pin gpio 18 or another pin
how to insert in code this pin 17 to stay 2 sec when bluetooth is on and
pin 18 to stay 2 sec when bluetooth is off
thankyou