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

Bluetooth-Controlled Arduino Nano Relay Switch for Motor and LED

View and Edit Project In Cirkit DesignerImage of Bluetooth-Controlled Arduino Nano Relay Switch for Motor and LED

Circuit Documentation

Summary

This circuit is designed to control a DC motor and a 12V blue LED via an Arduino Nano, which is interfaced with an HC-05 Bluetooth module for wireless communication. The circuit also includes a 4-channel 5V relay module to switch the DC motor and LED on and off, a 16x2 I2C LCD for display purposes, and a 5V 5A power supply to power the components. Additionally, a 9V battery and a Li-ion 5000mAh battery are included to provide power to the motor and LED, respectively. The power supply is connected to a power outlet for AC input.

Component List

Arduino Nano

A compact microcontroller board based on the ATmega328P, featuring digital and analog I/O pins.

DC Motor

An electric motor that runs on direct current (DC) electricity.

12V Blue LED

A blue light-emitting diode that operates at 12 volts.

Relay 4 Channel 5V

A 4-channel relay module that allows for controlling high power devices with low power signals.

HC-05 Bluetooth Module

A Bluetooth module that enables wireless communication with the Arduino.

16x2 I2C LCD

A liquid crystal display with 16 characters by 2 lines, interfaced via the I2C protocol.

POWER SUPPLY 5V 5AMP

A power supply unit that converts 220V AC to 5V DC with a 5A current rating.

9V Battery

A standard 9V battery used to provide power to the circuit.

Li-ion 5000mAh Battery

A rechargeable lithium-ion battery with a capacity of 5000mAh and a nominal voltage of 11.1V.

Power Outlet (IL)

A power outlet interface for connecting the power supply to the AC mains.

Wiring Details

Arduino Nano

DC Motor

12V Blue LED

Relay 4 Channel 5V

HC-05 Bluetooth Module

16x2 I2C LCD

POWER SUPPLY 5V 5AMP

9V Battery

Li-ion 5000mAh Battery

Power Outlet (IL)

Documented Code

#include<EEPROM.h>
#include<SoftwareSerial.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2); // Adjust address if necessary

// Define relay pins
const int relayMotor = 4; // Relay channel for DC motor
const int relayLED = 5;   // Relay channel for LED module

// Define HC-05 Bluetooth Serial
#define BTSerial Serial

void setup() {
  // Set up relay pins
  pinMode(relayMotor, OUTPUT);
  pinMode(relayLED, OUTPUT);

  // Initially turn off all relays
  digitalWrite(relayMotor, HIGH); // Relay modules are typically active LOW
  digitalWrite(relayLED, HIGH);

  // Initialize LCD
  lcd.begin();
  lcd.backlight(); // Turn on the LCD backlight
  lcd.clear();
  lcd.print("Ready for Commands");

  // Initialize Serial for HC-05 Bluetooth
  BTSerial.begin(9600);  // Default baud rate for HC-05
}

void loop() {
  // Check if data is available from Bluetooth
  if (BTSerial.available()) {
    char command = BTSerial.read();

    // Process received command
    switch (command) {
      case '1': // Turn on LCD display
        lcd.display();
        lcd.backlight();
        lcd.clear();
        lcd.print("LCD is ON");
        break;

      case '2': // Turn off LCD display
        lcd.noDisplay();
        lcd.noBacklight();
        lcd.clear();
        break;

      case '3': // Turn on Motor
        digitalWrite(relayMotor, LOW); // Relay active LOW
        lcd.clear();
        lcd.print("Motor is ON");
        break;

      case '4': // Turn off Motor
        digitalWrite(relayMotor, HIGH); // Relay off
        lcd.clear();
        lcd.print("Motor is OFF");
        break;

      case '5': // Turn on LED
        digitalWrite(relayLED, LOW); // Relay active LOW
        lcd.clear();
        lcd.print("LED is ON");
        break;

      case '6': // Turn off LED
        digitalWrite(relayLED, HIGH); // Relay off
        lcd.clear();
        lcd.print("LED is OFF");
        break;

      default:
        lcd.clear();
        lcd.print("Unknown Command");
        break;
    }
    delay(1000); // Small delay for readability
  }
}

This code is designed to run on the Arduino Nano and controls the relay module to switch the DC motor and LED on and off based on commands received via Bluetooth. It also updates the LCD display with the status of the devices.