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

Arduino UNO Bluetooth-Controlled Robotic System with Water Pump

View and Edit Project In Cirkit DesignerImage of Arduino UNO Bluetooth-Controlled Robotic System with Water Pump

Circuit Documentation

Summary

This circuit is designed to control multiple motors and a water pump using an Arduino UNO microcontroller. The circuit includes a Bluetooth module for wireless communication, a motor driver for controlling the motors, a relay for controlling the water pump, and a rocker switch for power control. The Arduino UNO is programmed to receive commands via Bluetooth to control the motors and periodically activate the water pump.

Component List

  1. Arduino UNO

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. L298N DC Motor Driver

    • Description: Dual H-Bridge motor driver module.
    • Pins: OUT1, OUT2, 12V, GND, 5V, OUT3, OUT4, 5V-ENA-JMP-I, 5V-ENA-JMP-O, +5V-J1, +5V-J2, ENA, IN1, IN2, IN3, IN4, ENB
  3. 5V Mini Water Pump

    • Description: Small water pump powered by 5V.
    • Pins: positive pin, negative pin
  4. Motor amarillo motorreductor hobby

    • Description: Hobby motor with gearbox.
    • Pins: vcc, GND
  5. DC Motor

    • Description: Standard DC motor.
    • Pins: pin 1, pin 2
  6. Battery 12V

    • Description: 12V battery for power supply.
    • Pins: +, -
  7. 12V Single Channel Relay

    • Description: Relay module for switching high power devices.
    • Pins: NC, COM, NO, IN, GND, VCC
  8. Rocker Switch

    • Description: On/Off switch.
    • Pins: 1, 2
  9. HC-05 Bluetooth Module

    • Description: Bluetooth module for wireless communication.
    • Pins: Key, VCC, GND, TXD, RXD, State

Wiring Details

Arduino UNO

L298N DC Motor Driver

5V Mini Water Pump

DC Motor

Battery 12V

12V Single Channel Relay

Rocker Switch

HC-05 Bluetooth Module

Code Documentation

#include <SoftwareSerial.h>

#define IN1 2
#define IN2 3
#define IN3 4
#define IN4 5

#define RELAY_PIN 6 // Define pin for relay module

SoftwareSerial bt(11, 10); // RX, TX

char data;

void setup() {
  Serial.begin(9600);

  // Motor control pins
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);

  // Relay pin setup
  pinMode(RELAY_PIN, OUTPUT);

  // Set initial states
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
  digitalWrite(RELAY_PIN, LOW); // Ensure relay is OFF initially

  bt.begin(9600);
}

void loop() {
  // Bluetooth data handling
  while (bt.available()) {
    data = bt.read();
    Serial.println(data);

    switch (data) {
      case 'F':
        forward();
        break;

      case 'B':
        reverse();
        break;

      case 'L':
        left();
        break;

      case 'R':
        right();
        break;

      case 'S':
        stoprobot();
        break;
    }
  }

  // No Bluetooth data handling
  if (bt.available() < 0) {
    //Serial.println("No Bluetooth Data");
  }

  // Activate water pump via relay every 5 seconds
  activateWaterPump();

  delay(100);
}

void forward() {
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
  delay(20);
}

void reverse() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
  delay(20);
}

void left() {
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
  delay(20);
}

void right() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
  delay(20);
}

void stoprobot() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
  delay(20);
}

// Function to activate the water pump via relay
void activateWaterPump() {
  static unsigned long lastActivation = 0;
  unsigned long currentMillis = millis();

  // Check if 5 seconds have passed since the last activation
  if (currentMillis - lastActivation >= 500