Bluetooth Mobile Robot wih Maker Drive

In this tutorial, I’ll share with you on how to build a mobile robot using a Maker Drive. Before this we’re using an L298N motor driver and now we’re going to change it to Maker Drive and here are the reasons why:

  1. Easy to troubleshoot with the push button and LED indicator.
  2. Support motor voltage from  2.5V to 9.5VDC
  3. Solid state components provide faster response time and eliminate the wear and tear of mechanical relay
  4. 5V Output (200mA) to power the controller with minimum input voltage of 2.5V.

HARDWARE PREPARATION

This tutorial use :

  1. Maker UNO Bluetooth Robot Kit
  2. Maker Drive

You can make the hardware connection based on the diagram and table below.

Connection
Maker Drive M1AMaker UNO: Pin 3
Maker Drive M1BMaker UNO: Pin 9
Maker Drive 5VMaker UNO: 5V
Maker Drive GNDMaker UNO: GND
Maker Drive M2AMaker UNO: 10
Maker Drive M2BMaker UNO: 11
Bluetooth HC05 : TXMaker UNO: Pin 2
Bluetooth HC05 : RXMaker UNO: Pin 4
Bluetooth HC05 : VCCMaker Drive: 5V
Bluetooth HC05 : GNDMaker UNO: GND

Sample Code

This is the sample code used for this tutorial. Try it!

#define BT_TX 4
#define BT_RX 2
#include "SoftwareSerial.h"
SoftwareSerial BTSerial(BT_TX, BT_RX); // Maker UNO RX, TX
#include "CytronMotorDriver.h"
// Configure the motor driver.
CytronMD motor1(PWM_PWM, 3, 9); // PWM 1A = Pin 3, PWM 1B = Pin 9.
CytronMD motor2(PWM_PWM, 10, 11); // PWM 2A = Pin 10, PWM 2B = Pin 11.
#define BUTTON 2
#define PIEZO 8
#define NOTE_G4 392
#define NOTE_C5 523
#define NOTE_G5 784
#define NOTE_C6 1047
int btConnect[] = {NOTE_G5, NOTE_C6};
int btConnectNoteDurations[] = {12, 8};
int btDisconnect[] = {NOTE_C5, NOTE_G4};
int btDisconnectNoteDurations[] = {12, 8};
#define playBtConnectMelody() playMelody(btConnect, btConnectNoteDurations, 2)
#define playBtDisconnectMelody() playMelody(btDisconnect, btDisconnectNoteDurations, 2)
boolean BTConnect = false;
char inChar;
String inString;
void setup()
{
pinMode(BUTTON, INPUT_PULLUP);
Serial.begin(9600);
BTSerial.begin(9600);
delay(1000);
}
void loop()
{
if (BTSerial.available()) {
if (BTConnect == false) {
BTConnect = true;
playBtConnectMelody();
}
inString = "";
while (BTSerial.available()) {
inChar = BTSerial.read();
inString = inString + inChar;
}
Serial.println(inString);
if (inString == "#b=0#") {
robotStop();
}
else if (inString == "#b=9#" ||
inString == "#b=19#" ||
inString == "#b=29#" ||
inString == "#b=39#" ||
inString == "#b=49#") {
robotBreak();
}
else if (inString == "#b=1#") {
robotForward();
}
else if (inString == "#b=2#") {
robotReverse();
}
else if (inString == "#b=3#") {
robotTurnLeft();
}
else if (inString == "#b=4#") {
robotTurnRight();
}
else if (inString.startsWith("+DISC")) {
BTConnect = false;
delay(1000);
while (BTSerial.available()) {
BTSerial.read();
}
playBtDisconnectMelody();
}
}
}
void playMelody(int *melody, int *noteDurations, int notesLength)
{
pinMode(PIEZO, OUTPUT);
for (int thisNote = 0; thisNote < notesLength; thisNote++) {
int noteDuration = 1000 / noteDurations[thisNote];
tone(PIEZO, melody[thisNote], noteDuration);
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
noTone(PIEZO);
}
}
void robotStop()
{
motor1.setSpeed(0); // Motor 1 stops.
motor2.setSpeed(0); // Motor 2 stops.
}
void robotForward()
{
motor1.setSpeed(200); // Motor 1 runs forward.
motor2.setSpeed(200); // Motor 2 runs forward.
}
void robotReverse()
{
motor1.setSpeed(-200); // Motor 1 runs backward.
motor2.setSpeed(-200); // Motor 2 runs backward.
}
void robotTurnLeft()
{
motor1.setSpeed(-200); // Motor 1 runs forward.
motor2.setSpeed(200); // Motor 2 runs backward.
}
void robotTurnRight()
{
motor1.setSpeed(200); // Motor 1 runs backward.
motor2.setSpeed(-200); // Motor 2 runs forkward.
}
void robotBreak()
{
motor1.setSpeed(0); // Motor 1 stops.
motor2.setSpeed(0); // Motor 2 stops.
}

Thank you

Thank you for reading this tutorial and we hope it helps your project development. If you have any technical inquiry, please post at Cytron Technical Forum.

2 thoughts on “Bluetooth Mobile Robot wih Maker Drive”

  1. Hi,
    The Maker Driver board connection to Maker UNO board shown in video is different from the sample code.

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

Ultrasonic HC-SR04P Using Raspberry Pi Pico
Object Sense With Servo Using Maker Pi RP2040
Build Otto DIY Robot Using Maker Pi RP2040
Raspberry Pi RP2040 vs STM32F1 vs SAMD21G18 vs ESP32-S2
The Easiest Way to Print Temperature Tower Using Cura 4.9.1 Plugins
Tutorials of Cytron Technologies Scroll to Top