Secure Passcode Smartphone-Controlled Garage Door
by TechMartian in Circuits > Wireless
1615 Views, 20 Favorites, 0 Comments
Secure Passcode Smartphone-Controlled Garage Door
This is a secure remote garage door opener controlled by your smartphone. It works by connecting to a the switch over bluetooth, which is activated upon entering the correct passcode.
Source an Outlet
Find an outlet near the garage door switch inside your garage. If it is not close enough grab an extension cable since we will be using a smartphone power brick and a printer cable like shown in the photo above to power the Arduino and Servo Motor.
Position the Switch
Position the servo motor and the Arduino right next to the switch and secure it with some hot glue and tape combination. Make sure that the positioning of the servo horn is such that it collides with the switch when rotated.
Wiring
* Connect the brown pin to GND
* Connect the red pin to 5V
* Connect the Orange pin to pin 9.
Code
Change your passcode, mine is 22 but yours could be any number you choose!
#include <CurieBLE.h>
<curieble.h> #include <Servo.h><servo.h> BLEPeripheral blePeripheral; // BLE Peripheral Device (the board you're programming) BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE LED Service</servo.h></curieble.h>
//set BLE characteristic BLEUnsignedCharCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);
const int servoPin = 7; const int passCode = 22;
Servo servo1;
void setup() { //attach servo servo1.attach(servoPin); // set advertised local name and service UUID: blePeripheral.setLocalName("Tech Martian"); blePeripheral.setAdvertisedServiceUuid(ledService.uuid());
// add service and characteristic: blePeripheral.addAttribute(ledService); blePeripheral.addAttribute(switchCharacteristic);
// set the initial value for the characeristic: switchCharacteristic.setValue(0);
// begin advertising BLE service: blePeripheral.begin();
servo1.write (90); }
void loop() { // listen for BLE peripherals to connect: BLECentral central = blePeripheral.central();
// if a central is connected to peripheral: if (central) { // while the central is still connected to peripheral: while (central.connected()) { // if the remote device wrote to the characteristic, // use the value to control the LED: if (switchCharacteristic.written()) { // any value other than 0, turn on the LED if (switchCharacteristic.value() == passCode) { servo1.write (90); } //else lockout for 5 minutes else { servo1.write (180); delay(5*60*1000); } } } } }
Done!
Enjoy a more secure and convenient to open garage door!