Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Nano-Based Remote-Controlled Relay System for LED, Light, and Motor

View and Edit Project In Cirkit DesignerImage of Arduino Nano-Based Remote-Controlled Relay System for LED, Light, and Motor

Circuit Documentation

Summary

This circuit is designed to control a 4-channel relay module using an Arduino Nano and a FlySky receiver. The receiver channels CH4, CH5, and CH6 are used to control the relays connected to pins D5, D6, D7, and D8 of the Arduino Nano. CH4 controls a yellow LED, CH5 controls a green light, and CH6 controls a DC motor in forward and backward directions. The circuit also includes a DC power source and a DC-DC converter to manage power distribution.

Component List

Arduino Nano

Relay 4 Channel 5v

DC Power Source

DC Motor

RC Receiver 6 Channels

Green Light 220VAC

Pilot LED Yellow

DC-DC Converter

Wiring Details

Arduino Nano

Relay 4 Channel 5v

DC Power Source

DC Motor

RC Receiver 6 Channels

Green Light 220VAC

Pilot LED Yellow

DC-DC Converter

Code Documentation

/*
 * This Arduino Sketch controls a 4-channel relay module using an Arduino Nano
 * and a FlySky receiver. The receiver channels CH4, CH5, and CH6 are used to
 * control the relays connected to pins D5, D6, D7, and D8 of the Arduino Nano.
 * CH4 controls a yellow LED, CH5 controls a green light, and CH6 controls a
 * DC motor in forward and backward directions.
 */

// Pin definitions
const int relay1Pin = 5; // Relay 1 connected to D5 (Yellow LED)
const int relay2Pin = 6; // Relay 2 connected to D6 (Green Light)
const int relay3Pin = 7; // Relay 3 connected to D7 (DC Motor)
const int relay4Pin = 8; // Relay 4 connected to D8 (DC Motor)

// Receiver channel pins
const int ch4Pin = 4; // CH4 connected to D4
const int ch5Pin = 3; // CH5 connected to D3
const int ch6Pin = 2; // CH6 connected to D2

void setup() {
  // Initialize relay pins as outputs
  pinMode(relay1Pin, OUTPUT);
  pinMode(relay2Pin, OUTPUT);
  pinMode(relay3Pin, OUTPUT);
  pinMode(relay4Pin, OUTPUT);

  // Initialize receiver channel pins as inputs
  pinMode(ch4Pin, INPUT);
  pinMode(ch5Pin, INPUT);
  pinMode(ch6Pin, INPUT);
}

void loop() {
  // Read receiver channel values
  int ch4Value = pulseIn(ch4Pin, HIGH);
  int ch5Value = pulseIn(ch5Pin, HIGH);
  int ch6Value = pulseIn(ch6Pin, HIGH);

  // Control yellow LED based on CH4 input
  if (ch4Value > 1500) {
    digitalWrite(relay1Pin, HIGH); // Turn on yellow LED
  } else {
    digitalWrite(relay1Pin, LOW); // Turn off yellow LED
  }

  // Control green light based on CH5 input
  if (ch5Value > 1500) {
    digitalWrite(relay2Pin, HIGH); // Turn on green light
  } else {
    digitalWrite(relay2Pin, LOW); // Turn off green light
  }

  // Control motor direction based on CH6 input
  if (ch6Value > 1500) {
    // Forward direction
    digitalWrite(relay3Pin, HIGH);
    digitalWrite(relay4Pin, LOW);
  } else if (ch6Value < 1500) {
    // Backward direction
    digitalWrite(relay3Pin, LOW);
    digitalWrite(relay4Pin, HIGH);
  } else {
    // Stop motor
    digitalWrite(relay3Pin, LOW);
    digitalWrite(relay4Pin, LOW);
  }
}

This code initializes the relay pins as outputs and the receiver channel pins as inputs. It reads the values from the receiver channels and controls the relays accordingly to turn on/off the yellow LED, green light, and control the direction of the DC motor.