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

Arduino UNO and L293D Bluetooth-Controlled Robotic Arm with Servo and Geared Motors

View and Edit Project In Cirkit DesignerImage of Arduino UNO and L293D Bluetooth-Controlled Robotic Arm with Servo and Geared Motors

Circuit Documentation

Summary

This circuit is designed to control a robotic system using an Arduino UNO microcontroller. The system includes a motor driver (L293D), two 12V geared motors, a 9G servo motor, and an HC-05 Bluetooth module. The Arduino UNO is programmed to receive commands via Bluetooth and control the motors and servo accordingly.

Component List

  1. L293D Motor Driver

    • Description: A quadruple high-current half-H driver designed to drive inductive loads such as relays, solenoids, DC and stepping motors.
    • Pins: 5V, GND, +, Servo1, Servo2, RX/DO, TX/D1, 9V, A0, A1, A2, A3, A4/SDA, A5/SCL, VIN, 3.3V, RESET, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13
  2. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P. It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.
    • 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
  3. 12V Geared Motor

    • Description: A DC motor with a gearbox attached to the shaft, providing higher torque at lower speeds.
    • Pins: Terminal 1, Terminal 2
  4. HC-05 Bluetooth Module

    • Description: A Bluetooth module used for wireless communication.
    • Pins: Key, VCC, TXD, RXD, State, GND
  5. Servo Motor 9G

    • Description: A small servo motor used for precise control of angular position.
    • Pins: VCC 5V, PMW, GND

Wiring Details

L293D Motor Driver

Arduino UNO

12V Geared Motor

HC-05 Bluetooth Module

Servo Motor 9G

Documented Code

#include <PS4BT.h>
#include <usbhub.h>
#include <Servo.h>

// USB and Bluetooth setup
USB Usb;
BTD Btd(&Usb);
PS4BT PS4(&Btd);

// Motor driver pins
#define IN1 8
#define IN2 9
#define IN3 10
#define IN4 11
#define IN5 4
#define IN6 5
#define IN7 6
#define IN8 7

// Servo motor pin
#define CLAW_PIN 3

// Servo motor object
Servo claw;

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

  // Initialize USB Host Shield
  if (Usb.Init() == -1) {
    Serial.println("USB Host Shield initialization failed.");
    while (1); // Halt
  }
  Serial.println("USB Host Shield initialized.");
  Serial.println("Press the PS button on the controller to connect.");

  // Motor setup
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
  pinMode(IN5, OUTPUT);
  pinMode(IN6, OUTPUT);
  pinMode(IN7, OUTPUT);
  pinMode(IN8, OUTPUT);

  // Initialize servo
  claw.attach(CLAW_PIN);
  claw.write(90); // Neutral position
}

void loop() {
  Usb.Task(); // Keep USB task running

  if (PS4.connected()) {
    handleMovement();
    handleClaw();
  }
}

void handleMovement() {
  int yAxis = PS4.getAnalogHat(LeftHatY); // Forward/Backward
  int xAxis = PS4.getAnalogHat(LeftHatX); // Left/Right

  if (yAxis > 137) { // Forward
    moveForward();
  } else if (yAxis < 117) { // Backward
    moveBackward();
  } else if (xAxis < 117) { // Turn Left
    turnLeft();
  }