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

Arduino Nano Bluetooth-Controlled DC Motor with Relay

View and Edit Project In Cirkit DesignerImage of Arduino Nano Bluetooth-Controlled DC Motor with Relay

Circuit Documentation

Summary

This circuit is designed to control a DC motor using an Arduino Nano and a 5V relay, with communication facilitated by an HC-05 Bluetooth module. The Arduino Nano receives commands via Bluetooth and controls the relay, which in turn powers the DC motor using a 9V battery.

Component List

  1. Arduino Nano

    • Description: A small, complete, and breadboard-friendly board based on the ATmega328P.
    • Pins: D1/TX, D0/RX, RESET, GND, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11/MOSI, D12/MISO, VIN, 5V, A7, A6, A5, A4, A3, A2, A1, A0, AREF, 3V3, D13/SCK
  2. HC-05 Bluetooth Module

    • Description: A Bluetooth module used for wireless communication.
    • Pins: Key, VCC, TXD, RXD, State, GND
  3. 9V Battery

    • Description: A standard 9V battery used to power the DC motor.
    • Pins: -, +
  4. 5V Relay

    • Description: An electromechanical switch used to control the DC motor.
    • Pins: Normally Open, Common terminal, Normally Closed, In, GND, VCC
  5. DC Motor

    • Description: A motor powered by DC voltage.
    • Pins: pin 1, pin 2

Wiring Details

Arduino Nano

HC-05 Bluetooth Module

9V Battery

5V Relay

DC Motor

Code Documentation

Arduino Nano Code

String readString;
#define relay1 3    

void setup()
{
  Serial.begin(9600);           
  pinMode(relay1, OUTPUT);      
  digitalWrite(relay1, LOW);     
}

void loop()
{
  while(Serial.available())    
  {
    delay(10);                 
    char c = Serial.read();    
    if (c == '#'){
      break;                   
    }
    readString += c;                
  }
  if (readString.length() > 0)
  {
    Serial.println(readString);
                  
    if (readString == "f success"){
      digitalWrite(relay1, HIGH);
      delay(3000);
      digitalWrite(relay1, LOW);
    }
    readString = "";
  }
}

This code initializes the serial communication and sets up the relay pin as an output. It reads incoming serial data and checks for a specific command ("f success"). When the command is received, it activates the relay for 3 seconds, which in turn powers the DC motor.