/*
* Bluetooh Basic: LED ON OFF - Avishkar
* Coder - Mayoogh Girish
* Website - http://bit.do/Avishkar
* Download the App :
* This program lets you to control a LED on pin 13 of arduino using a bluetooth module
*/
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int pos = 0;
int Red_LED = 13;
int Green_LED = 12;
char Incoming_value = 0; //Variable for storing Incoming_value
void setup()
{
Serial.begin(9600); //Sets the data rate in bits per second (baud) for serial data transmission
pinMode(Red_LED, OUTPUT); //Sets digital pin 13 as output pin
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
if(Serial.available() > 0)
{
Incoming_value = Serial.read(); //Read the incoming data and store it into variable Incoming_value
Serial.print(Incoming_value); //Print Value of Incoming_value in Serial monitor
Serial.print("\n"); //New line
if(Incoming_value == '1')
{
digitalWrite(Red_LED, HIGH); //If value is 1 then LED turns ON
myservo.write(0);
delay(1000);
Serial.println("Door Locked");
}
else if(Incoming_value == '0')
{
digitalWrite(Red_LED, LOW); //If value is 0 then LED turns OFF
digitalWrite(Green_LED, HIGH); //If value is 0 then LED turns OFF
myservo.write(180);
delay(1000);
Serial.println("Door UnLocked");
}
}
}
Bluetooth Door lock system
March 30, 2022
0
Tags
