Devices & Components
Arduino Uno Rev3
AC Wall Socket and Plug
HC-05 Bluetooth Module
M-F Jumper Wires
12V dc Adapter
5V Relay Module
UTSOURCE Electronic Parts
M-M Jumper wires
Software & Tools
MIT App Inventor
Project description
Code
The Sketch
c_cpp
1int relay = 12;//variable for assigning the relay module 2int state = 0;//variable for assigning the value communicated by bluetooth module 3int flag = 0; //variable for assigning flag to for a desirable operation 4void setup() 5{ 6 pinMode(relay, OUTPUT);//setting relay as output 7 digitalWrite(relay, LOW);// initializing the output as off 8 Serial.begin(9600); // default connection rate for the BT module 9} 10void loop() 11{ 12 if (Serial.available() > 0) //checking if connection available with bluetooth module 13 { 14 state = Serial.read();//assigning the value communicated by bluetooth module 15 flag = 0;//initial value set for flag 16 } 17 if (state == '0') // LOW value communicated by bluetooth module 18 { 19 digitalWrite(relay , LOW);//relay is switched OFF 20 if (flag == 0) //initial flag 21 { 22 Serial.println("POWER: Off");//display on the smartphone app 23 flag = 1;//flag toggled 24 } 25 } 26 else if (state == '1') //HIGH value communicated by bluetooth module 27 { 28 digitalWrite(relay, HIGH);// relay is turned ON 29 if (flag == 0)//initial flag 30 { 31 Serial.println("POWER: On");//display on the smartphone app 32 flag = 1;//flag toggled 33 } 34 } 35}
Downloadable files
CIRCUIT DIAGRAM
CIRCUIT DIAGRAM

CIRCUIT DIAGRAM
CIRCUIT DIAGRAM

Documentation
SMARTPLUG APP
SMARTPLUG APP
SMARTPLUG APP
SMARTPLUG APP
Comments
Only logged in users can leave comments