You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Design an Automatic Power on OFF system using Arduino Uno and Relay module #71
constint relayPin = 3; // Pin connected to the relay modulevoidsetup() {
pinMode(rainSensorPin, INPUT);
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, LOW); // Ensure the relay is initially off
}
voidloop() {
int sensorValue = digitalRead(rainSensorPin);
if (sensorValue == LOW) { // Rain detecteddigitalWrite(relayPin, HIGH); // Turn on relay (and thus the Raspberry Pi)
} else {
// Add delay functionality so that the Pi turns off itself based on inference values after some timedigitalWrite(relayPin, LOW); // Turn off relay (and thus the Raspberry Pi)
}
delay(1000); // Check every second
}
Activity
cksajil commentedon Jun 13, 2024