0% found this document useful (0 votes)
20 views1 page

2 Number Relay On and Off Arduino Programme

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

2 Number Relay On and Off Arduino Programme

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Here’s an Arduino program to control two relays, turning them ON and OFF alternately with a delay.

Code:

cpp

CopyEdit

// Define the relay pins int relay1 = 8; // Relay 1 connected to pin 8 int relay2 = 9; // Relay 2 connected to pin 9 void setup() { // Set relay pins as
OUTPUT pinMode(relay1, OUTPUT); pinMode(relay2, OUTPUT); // Initially turn both relays OFF digitalWrite(relay1, LOW); digitalWrite(relay2,
LOW); } void loop() { // Turn Relay 1 ON and Relay 2 OFF digitalWrite(relay1, HIGH); digitalWrite(relay2, LOW); delay(1000); // Wait for 1 second //
Turn Relay 1 OFF and Relay 2 ON digitalWrite(relay1, LOW); digitalWrite(relay2, HIGH); delay(1000); // Wait for 1 second }

Instructions:
1. Connect:
Relay 1 signal pin to Arduino pin 8, VCC to 5V, and GND to GND.
Relay 2 signal pin to Arduino pin 9, VCC to 5V, and GND to GND.

2. Upload the code to your Arduino board using the Arduino IDE.
3. The relays will toggle ON and OFF alternately with a 1-second interval.

If you want to customize the delay time or behavior, let me know!

You might also like