const int relay1 = 4; //Luci albero
const int relay2 = 16; //Laser
const int pb1 = 34;
const int pb2 = 35;
int relayON = HIGH;// relay menyala
int relayOFF = LOW;//relay mati
boolean hasil;//var tem cambiamento di stato
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode (relay1,OUTPUT);
digitalWrite (relay1,relayOFF);
pinMode (relay2,OUTPUT);
digitalWrite (relay2,relayOFF);
pinMode (pb1,INPUT);
pinMode (pb2,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
hasil = digitalRead (pb1);
if (hasil==1){
digitalWrite(relay1,relayON);
Serial.println("lampu 1 menyala!");
}else{
digitalWrite(relay1,relayOFF);
Serial.println("lampu 1 mati!");
}
hasil = digitalRead (pb2);
if (hasil==1){
digitalWrite(relay2,relayON);
Serial.println("lampu 2 menyala!");
}else{
digitalWrite(relay2,relayOFF);
Serial.println("lampu 2 mati!");
}
}