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

Arduino UNO Bluetooth-Controlled Robotic Car with Pan-Tilt Servos

View and Edit Project In Cirkit DesignerImage of Arduino UNO Bluetooth-Controlled Robotic Car with Pan-Tilt Servos

Circuit Documentation

Summary

This circuit is designed to control a two-wheel drive robot with a pan-tilt mechanism using an Arduino UNO. The robot is controlled via Bluetooth using the ArduinoBlue app. The circuit includes an Arduino UNO, an HM-10 Bluetooth module, two DC motors, two servo motors, an L298N motor driver, a rocker switch, and two 9V batteries.

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. Bluetooth module HM-10

    • Description: Bluetooth Low Energy (BLE) module for wireless communication.
    • Pins: BRK, RX, TX, GND, VCC, State
  3. Hobby Gearmotor with 48:1 gearbox

    • Description: DC motor with a 48:1 gearbox for increased torque.
    • Pins: pin 1, pin 2
  4. 9V Battery

    • Description: Power source for the circuit.
    • Pins: -, +
  5. Rocker switch

    • Description: Switch to control the power supply.
    • Pins: output, input
  6. L298N DC motor driver

    • Description: Dual H-Bridge motor driver to control the DC motors.
    • 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
  7. Servo Motor 9G

    • Description: Small servo motor for precise control.
    • Pins: VCC 5V, PMW, GND

Wiring Details

Arduino UNO

Bluetooth module HM-10

Hobby Gearmotor with 48:1 gearbox

Hobby Gearmotor with 48:1 gearbox

9V Battery

Rocker switch

L298N DC motor driver

Servo Motor 9G

Servo Motor 9G

Code Documentation

/*
 * ArduinoBlue app controlled 2 wheel drive and 2 servo pan tilt
 * This code interfaces with an HM-10 Bluetooth module to receive commands
 * from the ArduinoBlue app. It controls two DC motors via an L298N motor driver
 * and two servo motors for pan and tilt functionality.
 */

#include <Servo.h>

// Pin definitions
const int motor1Pin1 = 5;
const int motor1Pin2 = 6;
const int motor2Pin1 = 9;
const int motor2Pin2 = 10;
const int servo1Pin = 3;
const int servo2Pin = 11;

// Create Servo objects
Servo servo1;
Servo servo2;

void setup() {
  // Initialize motor control pins as outputs
  pinMode(motor1Pin1, OUTPUT);
  pinMode(motor1Pin2, OUTPUT);
  pinMode(motor2Pin1, OUTPUT);
  pinMode(motor2Pin2, OUTPUT);

  // Attach servos to their respective pins
  servo1.attach(servo1Pin);
  servo2.attach(servo2Pin);

  // Initialize serial communication for Bluetooth module
  Serial.begin(9600);
}

void loop() {
  // Check if data is available from the Bluetooth module
  if (Serial.available() > 0) {
    char command = Serial.read();
    handleCommand(command);
  }
}

void handleCommand(char command) {
  switch (command) {
    case 'F': // Move forward
      digitalWrite(motor1Pin1, HIGH);
      digitalWrite(motor1Pin2, LOW);
      digitalWrite(motor2Pin1, HIGH);
      digitalWrite(motor2Pin2, LOW);
      break;
    case 'B': // Move backward
      digitalWrite(motor1Pin1, LOW);
      digitalWrite(motor1Pin2, HIGH);
      digitalWrite(motor2Pin1, LOW);
      digitalWrite(motor2Pin2, HIGH);
      break;
    case 'L': // Turn left
      digitalWrite(motor1Pin1, LOW);
      digitalWrite(motor1Pin2, HIGH);
      digitalWrite(motor2Pin1, HIGH);
      digitalWrite(motor2Pin2, LOW);
      break;
    case 'R': // Turn right
      digitalWrite(motor1Pin1, HIGH);
      digitalWrite(motor1Pin2, LOW);
      digitalWrite(motor2Pin1, LOW);
      digitalWrite(motor2Pin2, HIGH);
      break;
    case 'S': // Stop
      digitalWrite(motor1Pin1, LOW);
      digitalWrite(motor1Pin2, LOW);
      digitalWrite(motor2Pin1, LOW);
      digitalWrite(motor2Pin2, LOW);
      break;
    case 'U': // Pan up
      servo1.write(servo1.read() + 10);
      break;
    case 'D': // Pan down
      servo1.write(servo1.read() - 10);
      break;
    case 'P': // Tilt up
      servo2.write(servo2.read() + 10);
      break;
    case 'T': // Tilt down
      servo2.write(servo2.read() - 10);
      break;
    default:
      // Do nothing for unrecognized commands
      break;
  }
}

This code interfaces with the HM-10 Bluetooth module to receive commands from the ArduinoBlue app. It controls two DC motors via an L298N motor driver and two servo motors for pan and tilt functionality. The commands include moving forward, backward, turning left, right, stopping, and controlling the pan-tilt mechanism.