Bluetooth control Appliances |
Arduino program
#include <SoftwareSerial.h>
SoftwareSerial mySerial(9,8); // RX, TX
#include <EEPROM.h>
char bt_data; // variable to receive data from the serial port
int relay1 = 12;
int relay2 = 10;
int relay3 = 13;
int relay4 = 11;
int L1, L2, L3, L4, stop=0;
int touch1 = A5;
int touch2 = A4;
int touch3 = A3;
int touch4 = A2;
void setup()
{
L1 = EEPROM.read(1);
L2 = EEPROM.read(2);
L3 = EEPROM.read(3);
L4 = EEPROM.read(4);
pinMode(touch1, INPUT);
pinMode(touch2, INPUT);
pinMode(touch3, INPUT);
pinMode(touch4, INPUT);
pinMode(relay1, OUTPUT); digitalWrite(relay1, L1);
pinMode(relay2, OUTPUT); digitalWrite(relay2, L2);
pinMode(relay3, OUTPUT); digitalWrite(relay3, L3);
pinMode(relay4, OUTPUT); digitalWrite(relay4, L4);
mySerial.begin(9600); // start serial communication at 9600bps
delay(500);
}
void loop()
{
if(mySerial.available()>0){bt_data = mySerial.read();}
//For Button First
if(bt_data == 'a')
{L1=1;EEPROM.write(1, L1);}
if(bt_data == 'A')
{L1=0;EEPROM.write(1, L1);}
//For Botton Seconde
if(bt_data == 'b')
{L2=1;EEPROM.write(2, L2);}
if(bt_data == 'B')
{L2=0;EEPROM.write(2, L2);}
//Load Button Third
if(bt_data == 'c')
{L3=1;EEPROM.write(3, L3);}
if(bt_data == 'C')
{L3=0;EEPROM.write(3, L3);}
//Load Button Foure
if(bt_data == 'd')
{L4=1;EEPROM.write(4, L4);}
if(bt_data == 'D')
{L4=0;EEPROM.write(4, L4);}
bt_data='0';
if (digitalRead (touch1) == 1 && stop==0)
{
stop=1;
L1 = L1+1;
if(L1>1)
{L1=0;}
EEPROM.write(1, L1);
delay(100);
}
if (digitalRead (touch2) == 1 && stop==0)
{
stop=1;
L2 = L2+1;
if(L2>1){L2=0;}
EEPROM.write(2, L2);
delay(100);
}
if (digitalRead (touch3) == 1 && stop==0)
{
stop=1;
L3 = L3+1;
if(L3>1){L3=0;}
EEPROM.write(3, L3);
delay(100);
}
if (digitalRead (touch4) == 1 && stop==0)
{
stop=1;
L4 = L4+1;
if(L4>1){L4=0;}
EEPROM.write(4, L4);
delay(100);
}
if (digitalRead (touch1) == 0 && digitalRead (touch2) == 0 && digitalRead (touch3) == 0 && digitalRead (touch4) == 0)
{
stop=0;
}
digitalWrite(relay1, L1);
digitalWrite(relay2, L2);
digitalWrite(relay3, L3);
digitalWrite(relay4, L4);
delay(100);
}
SoftwareSerial mySerial(9,8); // RX, TX
#include <EEPROM.h>
char bt_data; // variable to receive data from the serial port
int relay1 = 12;
int relay2 = 10;
int relay3 = 13;
int relay4 = 11;
int L1, L2, L3, L4, stop=0;
int touch1 = A5;
int touch2 = A4;
int touch3 = A3;
int touch4 = A2;
void setup()
{
L1 = EEPROM.read(1);
L2 = EEPROM.read(2);
L3 = EEPROM.read(3);
L4 = EEPROM.read(4);
pinMode(touch1, INPUT);
pinMode(touch2, INPUT);
pinMode(touch3, INPUT);
pinMode(touch4, INPUT);
pinMode(relay1, OUTPUT); digitalWrite(relay1, L1);
pinMode(relay2, OUTPUT); digitalWrite(relay2, L2);
pinMode(relay3, OUTPUT); digitalWrite(relay3, L3);
pinMode(relay4, OUTPUT); digitalWrite(relay4, L4);
mySerial.begin(9600); // start serial communication at 9600bps
delay(500);
}
void loop()
{
if(mySerial.available()>0){bt_data = mySerial.read();}
//For Button First
if(bt_data == 'a')
{L1=1;EEPROM.write(1, L1);}
if(bt_data == 'A')
{L1=0;EEPROM.write(1, L1);}
//For Botton Seconde
if(bt_data == 'b')
{L2=1;EEPROM.write(2, L2);}
if(bt_data == 'B')
{L2=0;EEPROM.write(2, L2);}
//Load Button Third
if(bt_data == 'c')
{L3=1;EEPROM.write(3, L3);}
if(bt_data == 'C')
{L3=0;EEPROM.write(3, L3);}
//Load Button Foure
if(bt_data == 'd')
{L4=1;EEPROM.write(4, L4);}
if(bt_data == 'D')
{L4=0;EEPROM.write(4, L4);}
bt_data='0';
if (digitalRead (touch1) == 1 && stop==0)
{
stop=1;
L1 = L1+1;
if(L1>1)
{L1=0;}
EEPROM.write(1, L1);
delay(100);
}
if (digitalRead (touch2) == 1 && stop==0)
{
stop=1;
L2 = L2+1;
if(L2>1){L2=0;}
EEPROM.write(2, L2);
delay(100);
}
if (digitalRead (touch3) == 1 && stop==0)
{
stop=1;
L3 = L3+1;
if(L3>1){L3=0;}
EEPROM.write(3, L3);
delay(100);
}
if (digitalRead (touch4) == 1 && stop==0)
{
stop=1;
L4 = L4+1;
if(L4>1){L4=0;}
EEPROM.write(4, L4);
delay(100);
}
if (digitalRead (touch1) == 0 && digitalRead (touch2) == 0 && digitalRead (touch3) == 0 && digitalRead (touch4) == 0)
{
stop=0;
}
digitalWrite(relay1, L1);
digitalWrite(relay2, L2);
digitalWrite(relay3, L3);
digitalWrite(relay4, L4);
delay(100);
}
Required Component
Relay module |
TTP223 Touch Sensor |
5v 1Amp Smps |
HC-05 Bluetooth module |
Arduino UNO |
https://bit.ly/34A1J81
For 8 Appliances control program
#include <SoftwareSerial.h>
SoftwareSerial mySerial(9,8); // RX, TX
#include <EEPROM.h>
char bt_data; // variable to receive data from the serial port
int relay1 = 2;
int relay2 = 3;
int relay3 = 4;
int relay4 = 5;
int relay5 = 6;
int relay6 = 7;
int relay7 = 10;
int relay8 = 11;
int L1, L2, L3, L4,L5, L6, L7, L8, stop=0;
int touch1 = A0;
int touch2 = A1;
int touch3 = A2;
int touch4 = A3;
int touch5 = A4;
int touch6 = A5;
int touch7 = 12;
int touch8 = 13;
void setup()
{
L1 = EEPROM.read(1);
L2 = EEPROM.read(2);
L3 = EEPROM.read(3);
L4 = EEPROM.read(4);
L5 = EEPROM.read(5);
L6 = EEPROM.read(6);
L7 = EEPROM.read(7);
L8 = EEPROM.read(8);
pinMode(touch1, INPUT);
pinMode(touch2, INPUT);
pinMode(touch3, INPUT);
pinMode(touch4, INPUT);
pinMode(touch5, INPUT);
pinMode(touch6, INPUT);
pinMode(touch7, INPUT);
pinMode(touch8, INPUT);
pinMode(relay1, OUTPUT); digitalWrite(relay1, L1);
pinMode(relay2, OUTPUT); digitalWrite(relay2, L2);
pinMode(relay3, OUTPUT); digitalWrite(relay3, L3);
pinMode(relay4, OUTPUT); digitalWrite(relay4, L4);
pinMode(relay5, OUTPUT); digitalWrite(relay5, L5);
pinMode(relay6, OUTPUT); digitalWrite(relay6, L6);
pinMode(relay7, OUTPUT); digitalWrite(relay7, L7);
pinMode(relay8, OUTPUT); digitalWrite(relay8, L8);
mySerial.begin(9600); // start serial communication at 9600bps
delay(500);
}
void loop()
{
if(mySerial.available()>0){bt_data = mySerial.read();}
//For Button First
if(bt_data == 'a')
{L1=1;EEPROM.write(1, L1);}
if(bt_data == 'A')
{L1=0;EEPROM.write(1, L1);}
//For Botton Seconde
if(bt_data == 'b')
{L2=1;EEPROM.write(2, L2);}
if(bt_data == 'B')
{L2=0;EEPROM.write(2, L2);}
//Load Button Third
if(bt_data == 'c')
{L3=1;EEPROM.write(3, L3);}
if(bt_data == 'C')
{L3=0;EEPROM.write(3, L3);}
//Load Button Foure
if(bt_data == 'd')
{L4=1;EEPROM.write(4, L4);}
if(bt_data == 'D')
{L4=0;EEPROM.write(4, L4);}
//For Button Five
if(bt_data == 'e')
{L5=1;EEPROM.write(5, L5);}
if(bt_data == 'E')
{L5=0;EEPROM.write(5, L5);}
//For Botton six
if(bt_data == 'f')
{L6=1;EEPROM.write(6, L6);}
if(bt_data == 'F')
{L6=0;EEPROM.write(6, L6);}
//Load Button seven
if(bt_data == 'g')
{L7=1;EEPROM.write(7, L7);}
if(bt_data == 'G')
{L7=0;EEPROM.write(7, L7);}
//Load Button eight
if(bt_data == 'h')
{L8=1;EEPROM.write(8, L8);}
if(bt_data == 'H')
{L8=0;EEPROM.write(8, L8);}
bt_data='0';
if (digitalRead (touch1) == 1 && stop==0)
{
stop=1;
L1 = L1+1;
if(L1>1)
{L1=0;}
EEPROM.write(1, L1);
delay(100);
}
if (digitalRead (touch2) == 1 && stop==0)
{
stop=1;
L2 = L2+1;
if(L2>1){L2=0;}
EEPROM.write(2, L2);
delay(100);
}
if (digitalRead (touch3) == 1 && stop==0)
{
stop=1;
L3 = L3+1;
if(L3>1){L3=0;}
EEPROM.write(3, L3);
delay(100);
}
if (digitalRead (touch4) == 1 && stop==0)
{
stop=1;
L4 = L4+1;
if(L4>1){L4=0;}
EEPROM.write(4, L4);
delay(100);
}
if (digitalRead (touch5) == 1 && stop==0)
{
stop=1;
L5 = L5+1;
if(L5>1) {L5=0;}
EEPROM.write(5, L5);
delay(100);
}
if (digitalRead (touch6) == 1 && stop==0)
{
stop=1;
L6 = L6+1;
if(L6>1){L6=0;}
EEPROM.write(6, L6);
delay(100);
}
if (digitalRead (touch7) == 1 && stop==0)
{
stop=1;
L7 = L7+1;
if(L7>1){L7=0;}
EEPROM.write(7, L7);
delay(100);
}
if (digitalRead (touch8) == 1 && stop==0)
{
stop=1;
L8 = L8+1;
if(L8>1){L8=0;}
EEPROM.write(8, L8);
delay(100);
}
if (digitalRead (touch1) == 0 && digitalRead (touch2) == 0 && digitalRead (touch3) == 0 && digitalRead (touch4) == 0 &&
digitalRead (touch5) == 0 && digitalRead (touch6) == 0 && digitalRead (touch7) == 0 && digitalRead (touch8) == 0)
{
stop=0;
}
digitalWrite(relay1, L1);
digitalWrite(relay2, L2);
digitalWrite(relay3, L3);
digitalWrite(relay4, L4);
digitalWrite(relay1, L5);
digitalWrite(relay2, L6);
digitalWrite(relay3, L7);
digitalWrite(relay4, L8);
delay(100);
}
How can I operate with 6 relay?
ReplyDeleteit simple add the function in programming and you can control not only 6 many more
ReplyDeletethis is the 6 Relay program
ReplyDelete#include
SoftwareSerial mySerial(9,8); // RX, TX
#include
char bt_data; // variable to receive data from the serial port
int relay1 = 2;
int relay2 = 3;
int relay3 = 4;
int relay4 = 5;
int relay5 = 6;
int relay6 = 7;
int L1, L2, L3, L4, L5, L6, stop=0;
int touch1 = A5;
int touch2 = A4;
int touch3 = A3;
int touch4 = A2;
int touch5 = A1;
int touch6 = A0;
void setup()
{
L1 = EEPROM.read(1);
L2 = EEPROM.read(2);
L3 = EEPROM.read(3);
L4 = EEPROM.read(4);
L5 = EEPROM.read(5);
L6 = EEPROM.read(6);
pinMode(touch1, INPUT);
pinMode(touch2, INPUT);
pinMode(touch3, INPUT);
pinMode(touch4, INPUT);
pinMode(touch5, INPUT);
pinMode(touch6, INPUT);
pinMode(relay1, OUTPUT); digitalWrite(relay1, L1);
pinMode(relay2, OUTPUT); digitalWrite(relay2, L2);
pinMode(relay3, OUTPUT); digitalWrite(relay3, L3);
pinMode(relay4, OUTPUT); digitalWrite(relay4, L4);
pinMode(relay5, OUTPUT); digitalWrite(relay5, L5);
pinMode(relay6, OUTPUT); digitalWrite(relay6, L6);
mySerial.begin(9600); // start serial communication at 9600bps
delay(500);
}
void loop()
{
if(mySerial.available()>0){bt_data = mySerial.read();}
//For Button First
if(bt_data == 'a')
{L1=1;EEPROM.write(1, L1);}
if(bt_data == 'A')
{L1=0;EEPROM.write(1, L1);}
//For Botton Seconde
if(bt_data == 'b')
{L2=1;EEPROM.write(2, L2);}
if(bt_data == 'B')
{L2=0;EEPROM.write(2, L2);}
//Load Button Third
if(bt_data == 'c')
{L3=1;EEPROM.write(3, L3);}
if(bt_data == 'C')
{L3=0;EEPROM.write(3, L3);}
//Load Button Foure
if(bt_data == 'd')
{L4=1;EEPROM.write(4, L4);}
if(bt_data == 'D')
{L4=0;EEPROM.write(4, L4);}
//Load Button fifth
if(bt_data == 'e')
{L5=1;EEPROM.write(5, L5);}
if(bt_data == 'E')
{L5=0;EEPROM.write(5, L5);}
//Load Button sisth
if(bt_data == 'f')
{L6=1;EEPROM.write(6, L6);}
if(bt_data == 'F')
{L6=0;EEPROM.write(6, L6);}
bt_data='0';
if (digitalRead (touch1) == 1 && stop==0)
{
stop=1;
L1 = L1+1;
if(L1>1)
{L1=0;}
EEPROM.write(1, L1);
delay(100);
}
if (digitalRead (touch2) == 1 && stop==0)
{
stop=1;
L2 = L2+1;
if(L2>1){L2=0;}
EEPROM.write(2, L2);
delay(100);
}
if (digitalRead (touch3) == 1 && stop==0)
{
stop=1;
L3 = L3+1;
if(L3>1){L3=0;}
EEPROM.write(3, L3);
delay(100);
}
if (digitalRead (touch4) == 1 && stop==0)
{
stop=1;
L4 = L4+1;
if(L4>1){L4=0;}
EEPROM.write(4, L4);
delay(100);
}
if (digitalRead (touch5) == 1 && stop==0)
{
stop=1;
L5 = L5+1;
if(L5>1){L5=0;}
EEPROM.write(5, L5);
delay(100);
}
if (digitalRead (touch6) == 1 && stop==0)
{
stop=1;
L6 = L6+1;
if(L6>1){L6=0;}
EEPROM.write(6, L6);
delay(100);
}
if (digitalRead (touch1) == 0 && digitalRead (touch2) == 0 && digitalRead (touch3) == 0 && digitalRead (touch4) == 0 && digitalRead (touch5) == 0 && digitalRead (touch6) == 0)
{
stop=0;
}
digitalWrite(relay1, L1);
digitalWrite(relay2, L2);
digitalWrite(relay3, L3);
digitalWrite(relay4, L4);
digitalWrite(relay5, L5);
digitalWrite(relay6, L6);
delay(100);
}
Thank you..
ReplyDeletebro..Wifi vala video kab upload kar rahe ho??
ReplyDeletecan we use 12 or more relays ?
ReplyDeleteyes you can use more then 12 through the other controller like arduino mega
ReplyDeleteIs it possible to combine a capacitive touch dimmer, bluetooth and wifi in one program? Using arduino nano33iot. I'd like to make a 24v ledstrip thats controllable by these 3 ways.
ReplyDeleteThe 3 functions are integrated in this arduino. thank you