Switch pumps, lamps, valves, and classroom loads through relay modules.
Open in compiler →/*
Roboda verified Arduino sample 0693
Feature: Relay Control
Generated for online build, classroom practice, and hardware upload testing.
*/
const byte relayPin = 7;
const unsigned long onTime = 770;
void setup() {
pinMode(relayPin, OUTPUT);
}
void loop() {
digitalWrite(relayPin, HIGH);
delay(onTime);
digitalWrite(relayPin, LOW);
delay(1000);
}
How it works
Practice this Arduino feature with a verified Roboda sketch.
- Read the constants at the top of the sketch.
- Wire the pins exactly as listed in the pin map.
- Upload or compile once before changing values.
- Change one value at a time and watch Serial Monitor or the output device.
Connections
| Pin | Connect to | Note |
|---|---|---|
| D7 | Relay module IN pin | Use a relay module/driver, not a bare relay coil from the Arduino pin. |