relay
.const int buttonPin = 10; const int relay = 13; int buttonState = 0; void setup() { pinMode(relay, OUTPUT); pinMode(buttonPin, INPUT); } void loop() { buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { digitalWrite( relay, LOW); delay(1000); // 10초 on digitalWrite(relay, HIGH); delay(1000); // 10초 off } else { digitalWrite(relay, HIGH); } }
2019 03 26 Smart Farm Auto Control with Arduino