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

Arduino UNO Bluetooth-Controlled Robot with Traffic Light Indicator and Servo Actuation

View and Edit Project In Cirkit DesignerImage of Arduino UNO Bluetooth-Controlled Robot with Traffic Light Indicator and Servo Actuation

Circuit Documentation

Summary

This circuit is designed to control a set of DC motors and a traffic light using an Arduino UNO microcontroller. The circuit includes motor drivers for controlling the motors, a Bluetooth module for wireless communication, logic level converters for voltage level adjustment, servomotors, and step-up boost power converters for voltage regulation. The Arduino UNO is programmed to interpret Bluetooth commands to drive the motors and control the traffic light, indicating a potential application in robotics or automated systems.

Component List

Arduino UNO

DC Motor (x3)

L298N DC Motor Driver (x2)

Bluetooth HC-06

Traffic Light

Step Up Boost Power Converter, Adjustable Voltage Regulator (x4)

Bi-Directional Logic Level Converter

Servomotor MG90S

Battery AAx4 6V

Wiring Details

Arduino UNO

DC Motor

L298N DC Motor Driver

Bluetooth HC-06

Traffic Light

Step Up Boost Power Converter, Adjustable Voltage Regulator

Bi-Directional Logic Level Converter

Servomotor MG90S

Battery AAx4 6V

Documented Code

#include <SoftwareSerial.h>

// Defining Bluetooth pins (RX, TX)
SoftwareSerial BT(10, 11); 

// Defining pins for the motors controlled by the H-bridges
int motorEsquerdaFrente = 3;
int motorEsquerdaTras = 4;
int motorDireitaFrente = 5;
int motorDireitaTras = 6;
int motorFrente = 7; // Pin for the front motor (tool)

void setup() {
  // Setting motor pins as outputs
  pinMode(motorEsquerdaFrente, OUTPUT);
  pinMode(motorEsquerdaTras, OUTPUT);
  pinMode(motorDireitaFrente, OUTPUT);
  pinMode(motorDireitaTras, OUTPUT);
  pinMode(motorFrente, OUTPUT);
  
  // Starting serial communication with Bluetooth
  BT.begin(9600);
  Serial.begin(9600);  // Communication with the serial monitor (optional)
}

void loop() {
  if (BT.available()) {
    char comando = BT.read();
    Serial.println(comando); // Displays the command on the serial monitor
    
    // Controls the motors based on the received command
    switch (comando) {
      case 'F': // Forward
        frente();
        break;
      case 'B': // Back
        tras();
        break;
      case 'L': // Left
        esquerda();
        break;
      case 'R': // Right
        direita();
        break;
      case 'S': // Stop
        parar();
        break;
      case 'T': // Activate front motor (tool)
        motorFerramenta(true);
        break;
      case 'X': // Deactivate front motor (tool)
        motorFerramenta(false);
        break;
    }
  }
}

// Functions to control the movement of the cart
void frente() {
  digitalWrite(motorEsquerdaFrente, HIGH);
  digitalWrite(motorEsquerdaTras, LOW);
  digitalWrite(motorDireitaFrente, HIGH);
  digitalWrite(motorDireitaTras, LOW);
}

void tras() {
  digitalWrite(motorEsquerdaFrente, LOW);
  digitalWrite(motorEsquerdaTras, HIGH);
  digitalWrite(motorDireitaFrente, LOW);
  digitalWrite(motorDireitaTras, HIGH);
}

void esquerda() {
  digitalWrite(motorEsquerdaFrente, LOW);
  digitalWrite(motorEsquerdaTras, HIGH);
  digitalWrite(motorDireitaFrente, HIGH);
  digitalWrite(motorDireitaTras, LOW);
}

void direita() {
  digitalWrite(motorEsquerdaFrente, HIGH);
  digitalWrite(motorEsquerdaTras, LOW);
  digitalWrite(motorDireitaFrente, LOW);
  digitalWrite(motorDireitaTras, HIGH);
}

void parar() {
  digitalWrite(motorEsquerdaFrente, LOW);
  digitalWrite(motorEsquerdaTras, LOW);
  digitalWrite(motorDireitaFrente, LOW);
  digitalWrite(motorDireitaTras, LOW);
}

void motorFerramenta(bool ativar) {
  if (ativar) {
    digitalWrite(motorFrente, HIGH);
  } else {
    digitalWrite(motorFrente, LOW);
  }
}

This code is designed to run on an Arduino UNO and controls various motors and a traffic light based on Bluetooth commands. It uses the SoftwareSerial library to create a serial communication channel with the Bluetooth module. The code defines functions for moving forward, backward, left, right, stopping, and controlling an additional front motor (tool). The loop function listens for incoming Bluetooth commands and calls the appropriate movement function.