Bluetooth Serial Relay and push button.

hi, i have been trying alot today. before this i found a sketch online on controling relays with bluetooth switch i made some modifications and used it.

i created an app from thunkable or app inventor then control it with my phone.

now i'm trying to add in a push button. here's the arduino sketch. i'm not sure what i did wrong. but the (pushButton) seems like its not working.

i have the my code below

Thanks for the help :slight_smile:

/*
simple LED test
*/

char val;         // variable to receive data from the serial port
const byte Relay1 = 2;  // LED connected to pin 2 (on-board LED)
const byte Relay2 = 3;
const byte Relay3 = 4;
const byte Relay4 = 5;
const byte Relay5 = 6;
const byte Relay6 = 7;
int pushButton = 9;

void setup()
{
  pinMode(Relay1, OUTPUT); // pin 2 () as OUTPUT
  pinMode(Relay2, OUTPUT); // pin 3 (on-board LED) as OUTPUT
  pinMode(Relay3, OUTPUT);
  pinMode(Relay4, OUTPUT);
  pinMode(Relay5, OUTPUT);
  pinMode(Relay6, OUTPUT);
  pinMode(pushButton, INPUT);  
  digitalWrite(Relay1, HIGH);
  digitalWrite(Relay2, HIGH);
  digitalWrite(Relay3, HIGH);
  digitalWrite(Relay4, HIGH);
  digitalWrite(Relay5, HIGH);
  digitalWrite(Relay6, HIGH);
  Serial.begin(9600);       // start serial communication at 115200bps
}

void loop()
{

  if ( Serial.available() > 0 )      // if data is available to read
  {
    val = Serial.read();         // read it and store it in 'val'
    
  if (pushButton == LOW) {
    // turn LED on:
      digitalWrite(Relay1, HIGH);    // turn Off pin 2
    }
    if ( val == 'a' )              // if 'a' was received led 2 is switched off
    {
      Serial.write ("a");
      digitalWrite(Relay1, HIGH);    // turn Off pin 2
    }

    if ( val == 'A' )              // if 'A' was received led 2 on
    {
      Serial.write ("A");
      digitalWrite(Relay1, LOW);  // turn ON pin 2
    }

    if ( val == 'b' )              // if 'b' was received led 3 is switched off
    {
      Serial.write ("b");
      digitalWrite(Relay2, HIGH);    // turn Off pin 3
    }

    if ( val == 'B' )              // if 'B' was received led 3 on
    {
      Serial.write ("b");
      digitalWrite(Relay2, LOW);  // turn ON pin 3
    } //else (ledpin = 3, LOW)        //set led pin 3 to low state
    
	  if ( val == 'c' )              // if 'a' was received led 2 is switched off
    {
      Serial.write ("c");
      digitalWrite(Relay3, HIGH);    // turn Off pin 2
    }

    if ( val == 'C' )              // if 'A' was received led 2 on
    {
      Serial.write ("C");
      digitalWrite(Relay3, LOW);  // turn ON pin 2
    }

    if ( val == 'd' )              // if 'b' was received led 3 is switched off
    {
      Serial.write ("d");
      digitalWrite(Relay4, HIGH);    // turn Off pin 3
    }

    if ( val == 'D' )              // if 'B' was received led 3 on
    {
      Serial.write ("D");
      digitalWrite(Relay4, LOW);  // turn ON pin 3
    } //else (ledpin = 3, LOW)        //set led pin 3 to low state
    //trying stuff

    if ( val == 'f' )              // if 'b' was received led 3 is switched off
    {
      Serial.write ("f");
      digitalWrite(Relay5, HIGH);    // turn Off pin 3
    }

    if ( val == 'F' )              // if 'B' was received led 3 on
    {
      Serial.write ("F");
      digitalWrite(Relay5, LOW);  // turn ON pin 3
    }
     if ( val == 'g' )              // if 'b' was received led 3 is switched off
    {
      Serial.write ("g");
      digitalWrite(Relay6, HIGH);    // turn Off pin 3
    }

    if ( val == 'G' )              // if 'B' was received led 3 on
    {
      Serial.write ("G");
      digitalWrite(Relay6, LOW);  // turn ON pin 3
    }
    if( val == 'e' )
    {
      Serial.write ("e");
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(400);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(199);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(202);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(433);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(367);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(434);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
    }
  }
}

The number 9 will never equal the number zero.

You forgot to read pin 9

thx for the reply.. i'm having problems understanding.. hahaha

how i was going to set pin 9 as pushbutton, then pinmode to input, then if the button is pressed which will be HIGH it will turn on a relay.
i'm not a pro programer.. but i can understand simple ones like block in thunkable.. or app inventor

i was going to set pin 9 as pushbutton

I don't know how to to that.

then pinmode to input,

You did that bit - good.

Now all you have to do is read the digital pin 9, and assign that value to a variable.

still not working :frowning: heres the is the updated sketch. i did add the read. is there anything i missed?

/*
simple LED test
*/

char val;         // variable to receive data from the serial port
char val2;         // variable to receive data from the serial port
const byte Relay1 = 2;  // LED connected to pin 2 (on-board LED)
const byte Relay2 = 3;
const byte Relay3 = 4;
const byte Relay4 = 5;
const byte Relay5 = 6;
const byte Relay6 = 7;
int pushButton = 9;

void setup()
{
  pinMode(Relay1, OUTPUT); // pin 2 () as OUTPUT
  pinMode(Relay2, OUTPUT); // pin 3 (on-board LED) as OUTPUT
  pinMode(Relay3, OUTPUT);
  pinMode(Relay4, OUTPUT);
  pinMode(Relay5, OUTPUT);
  pinMode(Relay6, OUTPUT);
  pinMode(pushButton, INPUT);  
  digitalWrite(Relay1, HIGH);
  digitalWrite(Relay2, HIGH);
  digitalWrite(Relay3, HIGH);
  digitalWrite(Relay4, HIGH);
  digitalWrite(Relay5, HIGH);
  digitalWrite(Relay6, HIGH);
  Serial.begin(9600);       // start serial communication at 115200bps
}

void loop()
{

  if ( Serial.available() > 0 )      // if data is available to read
  {
    val = Serial.read();         // read it and store it in 'val'
    val2 = digitalRead(pushButton);   // read the input pin
    
  if (val2 == LOW) {
    // turn LED on:
      digitalWrite(Relay1, HIGH);    // turn Off pin 2
    }
      if (val2 == HIGH) {
    // turn LED on:
      digitalWrite(Relay1, LOW);    // turn Off pin 2
    }
    if ( val == 'a' )              // if 'a' was received led 2 is switched off
    {
      Serial.write ("a");
      digitalWrite(Relay1, HIGH);    // turn Off pin 2
    }

    if ( val == 'A' )              // if 'A' was received led 2 on
    {
      Serial.write ("A");
      digitalWrite(Relay1, LOW);  // turn ON pin 2
    }

    if ( val == 'b' )              // if 'b' was received led 3 is switched off
    {
      Serial.write ("b");
      digitalWrite(Relay2, HIGH);    // turn Off pin 3
    }

    if ( val == 'B' )              // if 'B' was received led 3 on
    {
      Serial.write ("b");
      digitalWrite(Relay2, LOW);  // turn ON pin 3
    } //else (ledpin = 3, LOW)        //set led pin 3 to low state
    
	  if ( val == 'c' )              // if 'a' was received led 2 is switched off
    {
      Serial.write ("c");
      digitalWrite(Relay3, HIGH);    // turn Off pin 2
    }

    if ( val == 'C' )              // if 'A' was received led 2 on
    {
      Serial.write ("C");
      digitalWrite(Relay3, LOW);  // turn ON pin 2
    }

    if ( val == 'd' )              // if 'b' was received led 3 is switched off
    {
      Serial.write ("d");
      digitalWrite(Relay4, HIGH);    // turn Off pin 3
    }

    if ( val == 'D' )              // if 'B' was received led 3 on
    {
      Serial.write ("D");
      digitalWrite(Relay4, LOW);  // turn ON pin 3
    } //else (ledpin = 3, LOW)        //set led pin 3 to low state
    //trying stuff

    if ( val == 'f' )              // if 'b' was received led 3 is switched off
    {
      Serial.write ("f");
      digitalWrite(Relay5, HIGH);    // turn Off pin 3
    }

    if ( val == 'F' )              // if 'B' was received led 3 on
    {
      Serial.write ("F");
      digitalWrite(Relay5, LOW);  // turn ON pin 3
    }
     if ( val == 'g' )              // if 'b' was received led 3 is switched off
    {
      Serial.write ("g");
      digitalWrite(Relay6, HIGH);    // turn Off pin 3
    }

    if ( val == 'G' )              // if 'B' was received led 3 on
    {
      Serial.write ("G");
      digitalWrite(Relay6, LOW);  // turn ON pin 3
    }
    if( val == 'e' )
    {
      Serial.write ("e");
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(400);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(199);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(202);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(433);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(367);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(434);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
    }
  }
}

Did you provide a continuous stream of characters on the serial line, to allow pin 9 to be read?

BTW

    val2 = digitalRead(pushButton);   // read the input pin
   
  if (val2 == LOW) {
    // turn LED on:
      digitalWrite(Relay1, HIGH);    // turn Off pin 2
    }
      if (val2 == HIGH) {
    // turn LED on:
      digitalWrite(Relay1, LOW);    // turn Off pin 2
    }

is much more simply expressed digitalWrite (Relay1, ! digitalRead (pushButton));. It also neatly sidesteps the obvious/incorrect comments.

AWOL:
Did you provide a continuous stream of characters on the serial line, to allow pin 9 to be read?

i dont think i did.. how do i do that?

Look at your code.
The only way pin 9 gets read is if Serial.available returns a non-zero value.
I can't tell if that is what you intended

this is the actual code without the button.

i’m not really good at programing i need some examples so i can learn to add buttons that do the same as the serial commands… example if serial reads A it turns off a relay, and if i press a button it turns off or on the same relay.

i’m planing to use this a light switch. so i can turn off and on switches.

/*
simple LED test
*/

char val;         // variable to receive data from the serial port
const byte Relay1 = 2;  // LED connected to pin 2 (on-board LED)
const byte Relay2 = 3;
const byte Relay3 = 4;
const byte Relay4 = 5;
const byte Relay5 = 6;
const byte Relay6 = 7;

void setup()
{
  pinMode(Relay1, OUTPUT); // pin 2 () as OUTPUT
  pinMode(Relay2, OUTPUT); // pin 3 (on-board LED) as OUTPUT
  pinMode(Relay3, OUTPUT);
  pinMode(Relay4, OUTPUT);
  pinMode(Relay5, OUTPUT);
  pinMode(Relay6, OUTPUT);
  digitalWrite(Relay1, HIGH);
  digitalWrite(Relay2, HIGH);
  digitalWrite(Relay3, HIGH);
  digitalWrite(Relay4, HIGH);
  digitalWrite(Relay5, HIGH);
  digitalWrite(Relay6, HIGH);
  Serial.begin(9600);       // start serial communication at 115200bps
}

void loop()
{
  if ( Serial.available() > 0 )      // if data is available to read
  {
    val = Serial.read();         // read it and store it in 'val'

    if ( val == 'a' )              // if 'a' was received led 2 is switched off
    {
      digitalWrite(Relay1, HIGH);    // turn Off pin 2
    }

    if ( val == 'A' )              // if 'A' was received led 2 on
    {
      digitalWrite(Relay1, LOW);  // turn ON pin 2
    }

    if ( val == 'b' )              // if 'b' was received led 3 is switched off
    {
      digitalWrite(Relay2, HIGH);    // turn Off pin 3
    }

    if ( val == 'B' )              // if 'B' was received led 3 on
    {
      digitalWrite(Relay2, LOW);  // turn ON pin 3
    } //else (ledpin = 3, LOW)        //set led pin 3 to low state
	  if ( val == 'c' )              // if 'a' was received led 2 is switched off
    {
      digitalWrite(Relay3, HIGH);    // turn Off pin 2
    }

    if ( val == 'C' )              // if 'A' was received led 2 on
    {
      digitalWrite(Relay3, LOW);  // turn ON pin 2
    }

    if ( val == 'd' )              // if 'b' was received led 3 is switched off
    {
      digitalWrite(Relay4, HIGH);    // turn Off pin 3
    }

    if ( val == 'D' )              // if 'B' was received led 3 on
    {
      digitalWrite(Relay4, LOW);  // turn ON pin 3
    } //else (ledpin = 3, LOW)        //set led pin 3 to low state
    //trying stuff

    if ( val == 'f' )              // if 'b' was received led 3 is switched off
    {
      digitalWrite(Relay5, HIGH);    // turn Off pin 3
    }

    if ( val == 'F' )              // if 'B' was received led 3 on
    {
      digitalWrite(Relay5, LOW);  // turn ON pin 3
    }
     if ( val == 'g' )              // if 'b' was received led 3 is switched off
    {
      digitalWrite(Relay6, HIGH);    // turn Off pin 3
    }

    if ( val == 'G' )              // if 'B' was received led 3 on
    {
      digitalWrite(Relay6, LOW);  // turn ON pin 3
    }
    if( val == 'e' )
    {
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(400);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(199);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(202);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(433);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(367);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(434);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
    }
  }
}

Put the code in reply #6 before the "if (Serial.available..." code.

Try it.
Report back

Here is the code, now the relay1 is not working if i send serial. button also dosent work but the other relays work..

Thanks

/*
simple LED test
*/

char val;         // variable to receive data from the serial port
char val2;
const byte Relay1 = 2;  // LED connected to pin 2 (on-board LED)
const byte Relay2 = 3;
const byte Relay3 = 4;
const byte Relay4 = 5;
const byte Relay5 = 6;
const byte Relay6 = 7;
int pushButton = 9;

void setup()
{
  pinMode(Relay1, OUTPUT); // pin 2 () as OUTPUT
  pinMode(Relay2, OUTPUT); // pin 3 (on-board LED) as OUTPUT
  pinMode(Relay3, OUTPUT);
  pinMode(Relay4, OUTPUT);
  pinMode(Relay5, OUTPUT);
  pinMode(Relay6, OUTPUT);
  pinMode(pushButton, INPUT);
  digitalWrite(Relay1, HIGH);
  digitalWrite(Relay2, HIGH);
  digitalWrite(Relay3, HIGH);
  digitalWrite(Relay4, HIGH);
  digitalWrite(Relay5, HIGH);
  digitalWrite(Relay6, HIGH);
  Serial.begin(9600);       // start serial communication at 115200bps
}

void loop()
{

    val2 = digitalRead(pushButton);   // read the input pin
   
   if (val2 == LOW)
    // turn LED on: 
    {
      digitalWrite(Relay1, HIGH);    // turn Off pin 2
    }  
   if (val2 == HIGH) 
    // turn LED on:
    {
      digitalWrite(Relay1, LOW);    // turn Off pin 2
    }
  
  if ( Serial.available() > 0 )      // if data is available to read
  {
    val = Serial.read();         // read it and store it in 'val'

    if ( val == 'a' )              // if 'a' was received led 2 is switched off
    {
      digitalWrite(Relay1, HIGH);    // turn Off pin 2
    }

    if ( val == 'A' )              // if 'A' was received led 2 on
    {
      digitalWrite(Relay1, LOW);  // turn ON pin 2
    }

    if ( val == 'b' )              // if 'b' was received led 3 is switched off
    {
      digitalWrite(Relay2, HIGH);    // turn Off pin 3
    }

    if ( val == 'B' )              // if 'B' was received led 3 on
    {
      digitalWrite(Relay2, LOW);  // turn ON pin 3
    } //else (ledpin = 3, LOW)        //set led pin 3 to low state
    if ( val == 'c' )              // if 'a' was received led 2 is switched off
    {
      digitalWrite(Relay3, HIGH);    // turn Off pin 2
    }

    if ( val == 'C' )              // if 'A' was received led 2 on
    {
      digitalWrite(Relay3, LOW);  // turn ON pin 2
    }

    if ( val == 'd' )              // if 'b' was received led 3 is switched off
    {
      digitalWrite(Relay4, HIGH);    // turn Off pin 3
    }

    if ( val == 'D' )              // if 'B' was received led 3 on
    {
      digitalWrite(Relay4, LOW);  // turn ON pin 3
    } //else (ledpin = 3, LOW)        //set led pin 3 to low state
    //trying stuff

    if ( val == 'f' )              // if 'b' was received led 3 is switched off
    {
      digitalWrite(Relay5, HIGH);    // turn Off pin 3
    }

    if ( val == 'F' )              // if 'B' was received led 3 on
    {
      digitalWrite(Relay5, LOW);  // turn ON pin 3
    }
     if ( val == 'g' )              // if 'b' was received led 3 is switched off
    {
      digitalWrite(Relay6, HIGH);    // turn Off pin 3
    }

    if ( val == 'G' )              // if 'B' was received led 3 on
    {
      digitalWrite(Relay6, LOW);  // turn ON pin 3
    }
    if( val == 'e' )
    {
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(400);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(199);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(202);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(433);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(367);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(434);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
    }
  }
}

ok this one works.. if i hold the button the relay switches on.

now i need to be able to toggle with button and serial.

Thank you for the help

/*
simple LED test
*/
char val;         // variable to receive data from the serial port
char val2;
const byte Relay1 = 2;  // Relay Connected to pin 2
const byte Relay2 = 3;  // Relay Connected to pin 3
const byte Relay3 = 4;  // Relay Connected to pin 4
const byte Relay4 = 5;  // Relay Connected to pin 5
const byte Relay5 = 6;  // Relay Connected to pin 6
const byte Relay6 = 7;  // Relay Connected to pin 7
int pushButton = 9; // Push button connected to pin 9

void setup()
{
  pinMode(Relay1, OUTPUT); // pin 2 (Relay) as OUTPUT
  pinMode(Relay2, OUTPUT); // pin 3 (Relay) as OUTPUT
  pinMode(Relay3, OUTPUT); // pin 4 (Relay) as OUTPUT
  pinMode(Relay4, OUTPUT); // pin 5 (Relay) as OUTPUT
  pinMode(Relay5, OUTPUT); // pin 6 (Relay) as OUTPUT
  pinMode(Relay6, OUTPUT); // pin 7 (Relay) as OUTPUT
  pinMode(pushButton, INPUT); // pin 2 (button) as INPUT
  digitalWrite(Relay1, HIGH); // relay start at HIGH
  digitalWrite(Relay2, HIGH); // relay start at HIGH
  digitalWrite(Relay3, HIGH); // relay start at HIGH
  digitalWrite(Relay4, HIGH); // relay start at HIGH
  digitalWrite(Relay5, HIGH); // relay start at HIGH
  digitalWrite(Relay6, HIGH); // relay start at HIGH
  Serial.begin(9600);       // start serial communication at 115200bps
}

void loop()
{

   val2 = digitalRead(pushButton);   // read the pushbutton pin store in val2
   
   if (val2 == LOW)   // turn Relay off: 
    {
      Serial.write ("pushOn");            //send serial of pushbutton
      digitalWrite(Relay1, HIGH);    // turn Off relay1
      delay (100);
    }

   else if (val2 == HIGH) //turn relay 1 on
    {
      Serial.write ("pushOff");            //send serial of pushbutton
      digitalWrite(Relay1, LOW);    // turn On relay 1
      delay (100);
    }

  
  if ( Serial.available() > 0 )      // if data is available to read
  {
    val = Serial.read();         // read it and store it in 'val'
       
    if ( val == 'a' )              // if 'a' was received led 2 is switched off
    {
      Serial.write ("a");            //send serial 'a'
      digitalWrite(Relay1, HIGH);    // turn Off relay 1
    }

    if ( val == 'A' )              // if 'A' was received relay 1 on
    {
      Serial.write ("A");            //send serial 'A'
      digitalWrite(Relay1, LOW);  // turn ON relay 1
    }

    if ( val == 'b' )              // if 'b' was received relay 3 is switched off
    {
      Serial.write ("b");            //send serial 'b'
      digitalWrite(Relay2, HIGH);    // turn Off relay 2
    }

    if ( val == 'B' )              // if 'B' was received relay 2 on
    {
      Serial.write ("B");            //send serial 'B'
      digitalWrite(Relay2, LOW);  // turn ON relay 2
    } //else (ledpin = 3, LOW)        //set relay 2 to low state
    
	  if ( val == 'c' )              // if 'c' was received relay 3 is switched off
    {
      Serial.write ("c");            //send serial 'c'
      digitalWrite(Relay3, HIGH);    // turn Off relay 3
    }

    if ( val == 'C' )              // if 'C' was received relay 3 on
    {
      Serial.write ("C");         //send serial 'C'
      digitalWrite(Relay3, LOW);  // turn ON relay 3
    }

    if ( val == 'd' )              
    {
      Serial.write ("d");
      digitalWrite(Relay4, HIGH);  
    }

    if ( val == 'D' )             
    {
      Serial.write ("D");
      digitalWrite(Relay4, LOW);  
    } //else (ledpin = 3, LOW)       
    //trying stuff

    if ( val == 'f' )              
    {
      Serial.write ("f");
      digitalWrite(Relay5, HIGH);    
    }

    if ( val == 'F' )              
    {
      Serial.write ("F");
      digitalWrite(Relay5, LOW);  
    }
     if ( val == 'g' )              
    {
      Serial.write ("g");
      digitalWrite(Relay6, HIGH);   
    }

    if ( val == 'G' )              
    {
      Serial.write ("G");
      digitalWrite(Relay6, LOW);  
    }
    if( val == 'e' )
    {
      Serial.write ("e");
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(400);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(199);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(202);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(433);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(367);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
      delay(434);
      digitalWrite(Relay3, LOW);
      delay(34);
      digitalWrite(Relay3, HIGH);
    }
  }
}