Materials
- Arduino Uno
- Relay Module
- AC Light Bulb
- Power Cable
- Breadboard and Jumper Wires
Instructions
- Connect the relay module to the Arduino. Ensure the relay can handle the AC voltage.
- Wire the relay to the AC power source and the light bulb.
- Upload the following code to your Arduino:
const int relayPin = 8;
void setup() {
pinMode(relayPin, OUTPUT);
}
void loop() {
digitalWrite(relayPin, HIGH);
delay(5000);
digitalWrite(relayPin, LOW);
delay(5000);
}
Explanation
The relay module is used to switch the AC light bulb on and off. The code alternates the relay state every 5 seconds to control the light.
Conclusion
This project introduces home automation using Arduino. It’s a simple way to control household devices with programmable logic.