Bluetooth Automation app


download link for Bluetooth automation app
https://drive.google.com/file/d/1IlRQZIEuCVx62vypNzi-kJJkMtuSKjFG/view?usp=sharing




 

 Arduino sketch for Bluetooth Automation system


#include <SoftwareSerial.h> //including library for Software Serial communication
SoftwareSerial mySerial (2, 3); //(RX, TX)
                          
//defining all the pins of Arduino
#define s1 10
#define s2 11
#define s3 12
#define s4 13
void setup()
{
//setting all the pins
pinMode(s1, OUTPUT);
pinMode(s2, OUTPUT);
pinMode(s3, OUTPUT);
pinMode(s4, OUTPUT);
//defining baudrate
Serial.begin(9600);
mySerial.begin(9600);
}
void loop()
{
if (mySerial.available() == 1) //if communication is going on
{
char val = mySerial.read(); //Read the data recieved
Serial.println("Recieved data is " + (String) val);
if (val == 'A')
{
digitalWrite(s1, HIGH);
Serial.println("Switch 1 is ON");
}
if (val == 'a')
{
digitalWrite(s1, LOW);
Serial.println("Switch 1 is OFF");
}
if (val == 'B')
{
digitalWrite(s2, HIGH);
Serial.println("Switch 2 is ON");
}
if (val == 'b')
{
digitalWrite(s2, LOW);
Serial.println("Switch 2 is OFF");
}
if (val == 'C')
{
digitalWrite(s3, HIGH);
Serial.println("Switch 3 is ON");
}
if (val == 'c')
{
digitalWrite(s3, LOW);
Serial.println("Switch 3 is OFF");
}
if (val == 'D')
{
digitalWrite(s4, HIGH);
Serial.println("Switch 4 is ON");
}
if (val == 'd')
{
digitalWrite(s4, LOW);
Serial.println("Switch 4 is OFF");
}
if (val == 'E')
{
//digitalWrite(s5, HIGH);
Serial.println("Switch 5 is ON");
}
if (val == 'e')
{
//digitalWrite(s5, LOW);
Serial.println("Switch 5 is OFF");
}
if (val == 'F')
{
//digitalWrite(s6, HIGH);
Serial.println("Switch 6 is ON");
}
if (val == 'f')
{
//digitalWrite(s6, LOW);
Serial.println("Switch 6 is OFF");
}
if (val == 'G')
{
//digitalWrite(s7, HIGH);
Serial.println("Switch 7 is ON");
}
if (val == 'g')
{
//digitalWrite(s7, LOW);
Serial.println("Switch 7 is OFF");
}
if (val == 'H')
{
//digitalWrite(s8, HIGH);
Serial.println("Switch 8 is ON");
}
if (val == 'h')
{
//digitalWrite(s8, LOW);
Serial.println("Switch 8 is OFF");
}
if (val == 'I')
{
//digitalWrite(s9, HIGH);
Serial.println("Switch 9 is ON");
}
if (val == 'i')
{
//digitalWrite(s9, LOW);
Serial.println("Switch 9 is OFF");
}
}
}

Comments

Popular posts from this blog

4 Stage Timer With DS3231RTC Module.

Interfacing KY038 sound sensor with Raspberry pi Pico

Interfacing MQ2 Gas & Smoke Sensor With Raspberry Pi Pico