The circuit in question is designed to interface an Arduino UNO with multiple relay modules and an IR receiver. The Arduino UNO is used as the central processing unit, controlling the relay modules based on the input from the IR receiver. The relay modules allow the Arduino to control higher power devices, while the IR receiver enables remote control functionality.
#include <IRremote.h>
// IR Remote HEX codes for buttons
// Button codes are commented next to the corresponding actions
const int RECV_PIN = 7; // IR receiver pin connected to Arduino D7
IRrecv irrecv(RECV_PIN);
decode_results results;
// Relay control pins connected to Arduino D8-D12
#define rly1 8
#define rly2 9
#define rly3 10
#define rly4 11
#define rly5 12
void setup() {
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
irrecv.blink13(true); // Blink the onboard LED with each IR signal received
// Initialize relay control pins as outputs and set to HIGH (relays OFF)
pinMode(rly1, OUTPUT);
pinMode(rly2, OUTPUT);
pinMode(rly3, OUTPUT);
pinMode(rly4, OUTPUT);
pinMode(rly5, OUTPUT);
digitalWrite(rly1, HIGH);
digitalWrite(rly2, HIGH);
digitalWrite(rly3, HIGH);
digitalWrite(rly4, HIGH);
digitalWrite(rly5, HIGH);
}
void loop() {
if (irrecv.decode(&results)) { // Check if an IR signal has been received
Serial.println(results.value, HEX); // Print the HEX code of the received signal
// Perform actions based on the received IR signal
// Each if statement corresponds to a button on the remote
// The corresponding relay is switched ON, others are OFF
if (results.value == 0x1FE50AF || results.value == 0x264C7D03) { // Button 1
digitalWrite(rly1, LOW);
digitalWrite(rly2, HIGH);
digitalWrite(rly3, HIGH);
digitalWrite(rly4, HIGH);
digitalWrite(rly5, HIGH);
Serial.println("One Pressed");
}
// Additional button actions would be added here following the same pattern
irrecv.resume(); // Prepare to receive the next IR signal
}
}
This code is designed to run on the Arduino UNO and uses the IRremote library to decode IR signals from a remote control. The received signals are used to control the state of the relays, allowing for remote operation of connected devices. Each button press on the remote is associated with a specific relay action, toggling the connected device on or off.