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

Arduino Mega 2560 Bluetooth-Controlled Robotic Vehicle with Ultrasonic Sensor

View and Edit Project In Cirkit DesignerImage of Arduino Mega 2560 Bluetooth-Controlled Robotic Vehicle with Ultrasonic Sensor

Circuit Documentation

Summary

This circuit is designed to control multiple motors using an Arduino Mega 2560 and an L293D motor driver shield. It also includes an HC-05 Bluetooth module for wireless communication, an ultrasonic sensor for distance measurement, and LEDs for visual indicators. The circuit is powered by a 9V battery.

Component List

  1. Motor with reducer

    • Pins: 3 - 6 VCC, GND
    • Description: A motor with an integrated reducer for controlling speed and torque.
  2. L293D Driver Shield

    • Pins: 5V, GND, A0, A1, A2, A3, A4, A5, M+, M2, M1, M3, M4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, gnd, Aref, ser1, Servo2, +, -, 9V
    • Description: A motor driver shield for controlling DC motors and servos.
  3. 9V Battery

    • Pins: +, -
    • Description: A 9V battery for powering the circuit.
  4. HC-05 Bluetooth Module

    • Pins: Key, VCC, GND, TXD, RXD, State
    • Description: A Bluetooth module for wireless communication.
  5. Arduino Mega 2560

    • Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, D21/SCL, D20/SDA, D19/RX1, D18/TX1, D17 PWM/RX2, D16 PWM/TX2, D15/RX3, D14/TX3, D0 RX0, D1 TX0, D2 PWM, D3 PWM, D4 PWM, D5 PWM, D6 PWM, D7 PWM, D8 PWM, D9 PWM, D10 PWM, D11 PWM, D12 PWM, D13 PWM, AREF, SDA, SCL, D52, D50, D48, D46, D44, D42, D40, D38, D36, D34, D32, D30, D28, D26, D24, D22, D53, D51, D49, D47, D45, D43, D41, D39, D37, D35, D33, D31, D29, D27, D25, D23, 6swdw
    • Description: A microcontroller board based on the ATmega2560.
  6. Resistor

    • Pins: pin1, pin2
    • Description: A resistor with a resistance of 200 Ohms.
  7. Ultrasonic Sensor

    • Pins: +VCC, Trigger, Echo, GND
    • Description: A sensor for measuring distance using ultrasonic waves.
  8. LED: Two Pin (red)

    • Pins: cathode, anode
    • Description: A red LED for visual indication.
  9. LED: Two Pin (green)

    • Pins: cathode, anode
    • Description: A green LED for visual indication.

Wiring Details

Motor with reducer

L293D Driver Shield

9V Battery

HC-05 Bluetooth Module

Arduino Mega 2560

Resistor

Ultrasonic Sensor

LED: Two Pin (red)

LED: Two Pin (green)

Code Documentation

#include <AFMotor.h>          // Inclure la bibliothèque pour contrôler les moteurs CC avec un driver Adafruit
#include <Servo.h>            // Inclure la bibliothèque pour contrôler les servomoteurs

AF_DCMotor motordroite(1);    // Définir le moteur droit et le port auquel il est connecté
AF_DCMotor motorgauche(4);    // Définir le moteur gauche et le port auquel il est connecté
AF_DCMotor motorchaine(3);    // Définir le moteur de la chaîne et le port auquel il est connecté
char command;                 // Déclarer une variable pour stocker les commandes reçues

void setup() {
  Serial.begin(9600);         // Initialiser la communication série à 9600 bauds
  Serial1.begin(9600);        // Initialiser la communication série pour le module Bluetooth (RX1, pin 19)
  Serial2.begin(9600);        // Initialiser la communication série pour un autre module (RX2 si disponible)
  mot