#define relay1 12
#define relay2 11
#define relay3 10
#define relay4 9
#define relay5 8
#define relay6 7
#define relay7 6
#define relay8 5
int veri = 0;
void setup() {
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,HIGH);
digitalWrite(relay2,HIGH);
digitalWrite(relay3,HIGH);
digitalWrite(relay4,HIGH);
digitalWrite(relay5,HIGH);
digitalWrite(relay6,HIGH);
digitalWrite(relay7,HIGH);
digitalWrite(relay8,HIGH);
Serial.begin(9600);
}
void loop () {
veri = Serial.read();
if (veri == '1' ) {
digitalWrite(relay1,LOW);
Serial.println("relay1 ON");
}
if (veri == '2' ) {
digitalWrite(relay2,LOW);
Serial.println("relay1 ON");
}
if (veri == '3' ) {
digitalWrite(relay3,LOW);
Serial.println("relay1 ON");
}
if (veri == '4' ) {
digitalWrite(relay4,LOW);
Serial.println("relay1 ON");
}
if (veri == '5' ) {
digitalWrite(relay5,LOW);
Serial.println("relay1 ON");
}
if (veri == '6' ) {
digitalWrite(relay6,LOW);
Serial.println("relay1 ON");
}
if (veri == '7' ) {
digitalWrite(relay7,LOW);
Serial.println("relay1 ON");
}
if (veri == '8' ) {
digitalWrite(relay8,LOW);
Serial.println("relay1 ON");
}
if (veri == '0' ) {
digitalWrite(relay1,HIGH);
digitalWrite(relay2,HIGH);
digitalWrite(relay3,HIGH);
digitalWrite(relay4,HIGH);
digitalWrite(relay5,HIGH);
digitalWrite(relay6,HIGH);
digitalWrite(relay7,HIGH);
digitalWrite(relay8,HIGH);
Serial.println("relays OFF");
}
}