SmartLock
Our project is a smart door switch that utilizes a servo. The door (servo) will open when someone gets closer to the sonar sensor, and when it gets too close the door will lock, indicating that the user has enter the room. It can also be controlled through bluetooth, and shows open door and close door sound in each case.
Components
mbed | BLE |
---|---|
p28 | TX |
p27 | RX |
Vout | Vcc |
Gnd | Gnd |
SD | Mbed |
---|---|
CS | 8 (DigitalOut cs) |
DI | 5 (SPI mosi) |
VCC | VOUT |
SCK | 7 (SPI sclk) |
GND | GND |
DO | 6 (SPI miso) |
CD | nc |
mbed | AudioDriver |
---|---|
p18 | In+ |
Gnd | In- |
mbed | Servo |
---|---|
p21 | PWM |
External 5V | V+ |
Gnd | Gnd |
int main() { thread1.start(ble); thread2.start(speaker); // // // mu.startUpdates();//start measuring the distance while(1) { //Do something else here mu.checkDistance(); //call checkDistance() as much as possible, as this is where //the class checks if dist needs to be called. if (test <= 1 ) // open when something is close to the sensor { myLED1 = 1 ; myLED2 = 0; myLED3 = 0; myLED4 = 0; myservo = 1 ; close = true;} else if ( test > 1 and test <= 2 ) { myLED1 = 0 ; myLED2 = 1; myLED3 = 0; myLED4 = 0; open = false; close = false;} else if ( test > 2 and test <= 3 ) { myLED1 = 0 ; myLED2 = 0; myLED3 = 1; myLED4 = 0; open = false; close = false;} else if ( test > 3 and test <= 4 ) { myLED1 = 0 ; myLED2 = 0; myLED3 = 0; myLED4 = 1; open = false; close = false;} else if ( test > 5 and test <=8 ) // close when something is far away from the sensor { myLED1 = 1 ; myLED2 = 1; myLED3 = 1; myLED4 = 1; myservo = 0 ; open = true;} } }
Please log in to post comments.