int relay1=2,relay2=3,relay3=4,relay4=5,relay5=6,relay6=7,relay7=8,relay8=9;
char status;
void setup() {
Serial.begin(9600);
pinMode(relay1,OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3,OUTPUT);
pinMode(relay4,OUTPUT);
pinMode(relay5,OUTPUT);
pinMode(relay6,OUTPUT);
pinMode(relay7,OUTPUT);
pinMode(relay8,OUTPUT);
digitalWrite(relay1,LOW);
digitalWrite(relay2,LOW);
digitalWrite(relay3,LOW);
digitalWrite(relay4,LOW);
digitalWrite(relay5,LOW);
digitalWrite(relay6,LOW);
digitalWrite(relay7,LOW);
digitalWrite(relay8,LOW);
}
void loop() {
status=Serial.read();
if(status=='a')
{digitalWrite(relay1,HIGH);}
if(status=='b')
{digitalWrite(relay1,LOW);}
if(status=='c')
{digitalWrite(relay2,HIGH);}
if(status=='d')
{digitalWrite(relay2,LOW);}
if(status=='e')
{digitalWrite(relay3,HIGH);}
if(status=='f')
{digitalWrite(relay3,LOW);}
if(status=='g')
{digitalWrite(relay4,HIGH);}
if(status=='h')
{digitalWrite(relay4,LOW);}
if(status=='i')
{digitalWrite(relay5,HIGH);}
if(status=='j')
{digitalWrite(relay5,LOW);}
if(status=='k')
{digitalWrite(relay6,HIGH);}
if(status=='l')
{digitalWrite(relay6,LOW);}
if(status=='m')
{digitalWrite(relay7,HIGH);}
if(status=='n')
{digitalWrite(relay7,LOW);}
if(status=='o')
{digitalWrite(relay8,HIGH);}
if(status=='p')
{digitalWrite(relay8,LOW);}
}
Comments