int relay1 = 2;
int relay2 = 3;
int relay3 = 4;
int relay4 = 5;
int relay5 = 6;
int relay6 = 7;
int relay7 = 8;
int relay8 = 9;
void setup()
{
Serial.begin(9600);
Serial.flush();
digitalWrite(relay1,LOW);
digitalWrite(relay2,LOW);
digitalWrite(relay3,LOW);
digitalWrite(relay4,LOW);
digitalWrite(relay5,LOW);
digitalWrite(relay6,LOW);
digitalWrite(relay7,LOW);
digitalWrite(relay8,LOW);
pinMode(relay1, OUTPUT);//set relay pins as an output means arduino pin 2 give output...
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(relay4, OUTPUT);
pinMode(relay5, OUTPUT);
pinMode(relay6, OUTPUT);
pinMode(relay7, OUTPUT);
pinMode(relay8, OUTPUT);
}
void loop()
{
while (Serial.available()){
delay(10);
char bt = Serial.read();
switch (bt)
{
case 'C':
digitalWrite(relay1, HIGH);
break;
case'c':
digitalWrite(relay1,LOW);
break;
case 'B':
digitalWrite(relay3,HIGH);
break;
case'b':
digitalWrite(relay3,LOW);
break;
case 'A':
digitalWrite(relay2,HIGH);
break;
case'a':
digitalWrite(relay2,LOW);
break;
case 'I':
digitalWrite(relay4,HIGH);
break;
case'i':
digitalWrite(relay4,LOW);
break;
case 'D':
digitalWrite(relay5,HIGH);
break;
case'd':
digitalWrite(relay5,LOW);
break;
case 'F':
digitalWrite(relay6,HIGH);
break;
case'f':
digitalWrite(relay6,LOW);
break;
case'G':
digitalWrite(relay7,HIGH);
break;
case'g':
digitalWrite(relay7,LOW);
break;
case'E':
digitalWrite(relay8,HIGH);
break;
case'e':
digitalWrite(relay8,LOW);
break;
case'H':
digitalWrite(relay1,HIGH);
digitalWrite(relay2,HIGH);
digitalWrite(relay3,HIGH);
digitalWrite(relay4,HIGH);
digitalWrite(relay5,HIGH);
digitalWrite(relay6,HIGH);
digitalWrite(relay7,HIGH);
digitalWrite(relay8,HIGH);
break;
case'h':
digitalWrite(relay1,LOW);
digitalWrite(relay2,LOW);
digitalWrite(relay3,LOW);
digitalWrite(relay4,LOW);
digitalWrite(relay5,LOW);
digitalWrite(relay6,LOW);
digitalWrite(relay7,LOW);
digitalWrite(relay8,LOW);
break;
case'X':
digitalWrite(relay1,HIGH);
digitalWrite(relay4,HIGH);
break;
case'x':
digitalWrite(relay1,LOW);
digitalWrite(relay4,LOW);
break;
case'Y':
digitalWrite(relay2,HIGH);
digitalWrite(relay3,HIGH);
digitalWrite(relay7,HIGH);
digitalWrite(relay5,HIGH);
digitalWrite(relay6,HIGH);
digitalWrite(relay8,HIGH);
break;
case'y':
digitalWrite(relay2,LOW);
digitalWrite(relay3,LOW);
digitalWrite(relay7,LOW);
digitalWrite(relay5,LOW);
digitalWrite(relay6,LOW);
digitalWrite(relay8,LOW);
break;
case'l':
digitalWrite(relay2,LOW);
digitalWrite(relay7,LOW);
case'L':
digitalWrite(relay2,HIGH);
digitalWrite(relay7,HIGH);
break;
bt="";
}
delay(100);
}
}