Hi everyone my english is not perfect so sorry. I was interested of this video - YouTube and decided to start similar projet. I purchase Arduino Uno and oneHC-05 module.
Using MIT App Inventor I created an app.
The idea is:
when i press unlock on my mobile HC-05 to send "1" to arduino uno and to open relay 1. When release unlock HC-05 to send "2" and to close relay 1.
when i press lock on my mobile HC-05 to send "3" to arduino uno and to open relay 2. When release lock HC-05 to send "4" and to close relay 2.
when i press strar/stop on my mobile HC-05 to send "5" to arduino uno and to open relay 3. When release start/stop HC-05 to send "6" and to close relay 3.
when i press unlock on my mobile HC-05 to send "1" to arduino uno and to open relay 4. When press lock on my mobile HC-05 to send "3" and to close relay 4.
Here is code that I wrote:
#define Relay1 7
#define Relay2 9
#define Relay3 11
#define Relay4 13
void setup()
{
Serial.begin(9600);
digitalWrite(Relay1, HIGH);
digitalWrite(Relay2, HIGH);
digitalWrite(Relay3, HIGH);
digitalWrite(Relay4, HIGH);
pinMode(Relay1, OUTPUT);
pinMode(Relay2, OUTPUT);
pinMode(Relay3, OUTPUT);
pinMode(Relay4, OUTPUT);
}
void loop()
{
int incomingByte = 0;
if (Serial.available() > 0) {
incomingByte = Serial.parseInt();
}
if (incomingByte == 1) {
digitalWrite(Relay1, HIGH);
digitalWrite(Relay4, HIGH);
}
if (incomingByte == 2) {
digitalWrite(Relay1, LOW);
}
if (incomingByte == 3) {
digitalWrite(Relay2, HIGH);
digitalWrite(Relay4, LOW);
}
if (incomingByte == 4) {
digitalWrite(Relay2, LOW);
}
if (incomingByte == 5) {
digitalWrite(Relay3, HIGH);
}
if (incomingByte == 6) {
digitalWrite(Relay3, LOW);
}
}
Is there any mistakes in code? I also want to add other relay 5 it need to be open when HC-05 send "5" and to stay open for 30seconds after that to close but don't have an idea how to write this
I will keep in mind every sugestions