0

members

Easy Basics: Project 040d How to build the 4WD smart robot car Part 4 - Bluetooth HC-05 HC-06, L298N H-Br

of Acoptex.com in UNO

Basics: Project 040d

 Project name:  How to build the 4WD smart robot car Part 4 - Bluetooth HC-05 HC-06, L298N H-Bridge

Tags: Arduino, 4WD smart robot car, Arduino Uno R3, L298N H-Bridge motor driver module, LED, Bluetooth module HC-05, Bluetooth module HC-06, ZS-40, active piezo buzzer, software serial

Attachments: 

 4WDcarBluetoothHC05ZS40ATcommandssketch

4WDcarBluetoothHC06ZS40ATcommandssketch

4WDcarBluetoothHC05sketch

4WDcarBluetoothHC06sketch

4WDcarBluetoothHC05softsketch

4WDcarBluetoothHC06softsketch

In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):

1.Arduino Uno R3 (you can also use the other version of Arduino)

2. Bluetooth module HC-05, HC-06 2 pc

3.Arduino IDE ( you can download it from here  )

4.Jumper cables M-M, F-M, F-F

5. Breadboard 1 pc

6. Resistor 8 pcs (1 pc 1 KOhm, 1 pc 2KOhm and 6 pcs 220 Ohm)

7.4WD smart robot car set 1pc

8. L298N H-Bridge motor driver module (as you see they can be a little bit different but have the same working principle) 1pc

9. 6 x 1.5V AA Battery Box Case Holder with 6 pcs 1.5V AA batteries or Rechargeable 7.2V Power Supply (6 x 1.2V 1900 mAh) for motor driver module supply 1 pc

 

10. Arduino board power supply, can be from +7 to +12V DC (we used 9V battery with 9V Battery Clip and Barrel Jack) or 5V+ DC

 or

11. LED 6 pcs (2 pcs white for forward lights, 2 pcs red for back lights, 1 pc yellow for left turn, 1 pc blue for right turn)

12. Active Piezo buzzer 1 pc

13. Power switch 1 pc

14. Soldering Iron

General

We will learn how to connect different components and make Bluetooth controlled 4WD smart robot car. We will use bluetooth moduleS HC-05 and HC-06 ZS-40. We will also use software serial for easy programming.

WHAT IS A ROBOT?

Robot is an electromechanical device which is capable of reacting in some way to its environment, and take autonomous decisions or actions in order to achieve a specific task.

A robot is consists of following components:

1. Structure / Chassis

2. Actuator / Motor

3. Controller

4. Inputs / Sensors

5. Power Supply

The Structure consists of physical components. A robot has one or more physical components that move in some way to perform the task. In our case the Chassis and wheels are the structure of the robot.

An “Actuator” can be defined as a device that converts energy (in robotics, that energy tends to be electrical) into physical motion. Most of the actuators produce either rotational or linear motion. In our case the actuator is DC gear motor. It is basically a DC motor combined with a gearbox that works to decrease the motor’s speed and increase the torque. Example: A DC motor having speed 3000 rpm and torque 0.002 Nm. Now we add a gear to it with gear ratio 1:48. The new speed is reduce by a factor 48 (resulting 3000/44 = 68 rpm) and the torque increased by a factor of 48 (resulting 0.002 x 48 = 0.096 Nm).

Structure and Actuators without Controller means nothing. Your robot will still sit in one place. Its just like a human without life. So a Controller (brain) needed to move the robot from one place to another. It is a computing device capable of executing a program and is responsible for all computations, decision making, and communications. In our case, we are using an Arduino Uno microcontroller as a Controller. The Controller takes input (sensors, remote etc), process it and then gives a command to the actuator (motor) to do the desired task.

Unlike humans, robots are not limited to just sight, sound, touch, smell and taste. Robots use different Sensors to interact with the external world. A sensor is a device that detects and responds to some type of input from the physical environment. The specific input could be light, heat, motion, moisture, pressure, or any one of a great number of other environmental phenomena. The Inputsmay be from sensors, IR remote control or smartphone/tablet/PC. We will use IR remote control as a input device to control the 4WD smart robot car.

A robot needs a Power source to drive the actuators ( motors ) and the controller. Most of the robots are powered by a battery. When we talk about battery, there are lot of options:

  • AA Alkaline Battery ( Non Rechargeable )
  • AA NiMh or NiCd Battery ( Rechargeable )
  • Li Ion Battery
  • LiPo Battery

So according to the requirement choose the suitable one. In our opinion, always choose a rechargeable and sufficient capacity battery.

Understanding the Bluetooth modules HC-05 , HC-06

You can read more about them here.

Useful information about components

1. You can find information on how to assemble 4WD smart robot car set in How to build the 4WD smart robot car Part 1.

2. Understanding the L298N H-Bridge motor driver module

You can read more information here.

3. Understanding the DC motor

You can read more information here.

Signals and connections of the LED

The operating voltage of the LED is 1.8V and the operating current is 10mA-20mA. The Arduino Uno board can supply 5V or 3.3V power. We will use 5V for this project, so the minimum resistance of the current limiting resistor should be (5 V to 1.8 V)/20 = 160 Om. The 220 Om offered in the kit is suitable and you can also choose other resistors that meet the condition. The larger the resistance is, the dimmer the LED will get.

Signals and connections of the active piezo buzzer

Active piezo buzzer pin marked with (+) sign should be connected to Arduino Uno board digital pin which sends a signal, the other pin of active piezo buzzer should be connected to Arduino Uno board GND.

Signals and connections of Bluetooth modules HC-05 , HC-06

We are going to use Bluetooth modules HC-05 ZS-40 an HC-06 ZS-40 in this project. Read more about them and Bluetooth modules HC-05 FC-114 and HC-06 FC-114 here.

Build the circuit

The following picture shows the needed connections with the Arduino Uno

1. Wiring hardware serial


2. Wiring software serial


Step by Step instruction

The "blank" sketch won't work for "native USB" based Arduinos like the Leonardo, Micro, Zero, etc! Use the

Leo_passthru sketch instead!
  1. Assemble the 4WD robot car chassis (base). See How to build the 4WD smart robot car Part 1 (STEPS from 1 to 19).
  2. Attach L298N H-Bridge motor driver module to lower part of robot chassis using two medium size and two small size bolts.
  3. We will make four DC motors configuration with speed control. The L298N H-Bridge motor driver module logic and all DC motors will be powered from 7.2V power supply. 
  4. Set the 5V_EN (5V) regulator jumper, remove jumpers on ENA and +5V, ENB and +5V on the motor driver board. You can check the motor polarity by connecting it to the battery pack.If it rotates in forward direction (red wire with positive and black wire with negative terminal of the battery) then the connection is ok). Do not forget that you need to use PWM pin for speed control (can be 3,5,6,9,10,11) - ENA, ENB should be connected to PWM pins.
  5. Attach 6 jumper cables F-M to ENA, IN1, IN2, IN3, IN4, ENB pins of motor driver board.
  6. Attach to power terminal of motor driver module 1 pc of positive jumper cable M-M (male to male) and 2 pcs of negative (GND) jumper cable M-M (male to male
  7. Attach the top of robot chassis with four medium size bolts. Put the jumper cables out.
  8. Attach Arduino Uno board to top part of robot chassis using two copper collars, two medium size bolts and two small size bolts.
  9. Attach violet jumper cable (ENA) to Arduino Uno digital pin 9, yellow jumper cable (ENB) to Arduino Uno digital pin 6, blue jumper cable (IN1) to Arduino Uno digital pin 7, orange jumper cable (IN2) to Arduino Uno digital pin 10, yellow jumper cable (IN3) to Arduino Uno digital pin 5, green jumper cable (IN4) to Arduino Uno digital pin 4, one negative (GND) jumper cable from motor driver board to Arduino Uno GND pin.
  10. Prepare the power supply for motor driver board. Attach power switch to it.
  11. Attach power supply with tape or two bolts and two nuts to the top of robot chassis and connect to the power supply jumper cables.
  12. Do wiring for Bluetooth module, LEDs, active piezo buzzer on medium size board. You will need 15 x jumper cables M-M, 8 resistors, and 4 x jumper cables F-M. See on the picture below.
  13. Attach medium size breadboard to the top part of robot chassis. Connect jumper cables to Arduino Uno board.
  14. Open Arduino IDE on your PC/laptop.
  15. Plug your Adruino Uno board into your PC/laptop and select the correct board and com port.
  16. Attach 9V battery with 9V Battery Clip to the top of robot chassis but do not connect it to Arduino Jack.
  17. Verify and upload sketch to your Adruino Uno board. If you use sketch without software serial library (your bluetooth module connected to RX, TX (pins 0,1) of Arduino Uno board) - before uploading the sketch you should disconnect jumper cables from RX, TX (pins 0,1) of Arduino Uno board.
  18. Unplug your Adruino Uno board from your PC/laptop.
  19. Connect 9V battery with 9V Battery Clip and Barrel Jack to Arduino Jack.
  20. Turn the power switch (red switch) ON. 
  21. You Bluetooth controlled 4WD smart robot car is ready. Congrats!!! We need to prepare your smartphone/tablet now.
  22. Download and install Android App into your smartphone/tablet with Android OS - Arduino Bluetooth RC Car from Play market or here. We will use Samsung Galaxy Tab A 2016.
  23. To connect your smartphone/tablet with Anroid OS to Bluetooth module HC-05 or HC-06 you need to enter PIN CODE (PASSWORD) 1234 or 0000. Go to Bluetooth->Enable (ON)->Search for nearby devices->Pair->Enter password(pin code) on your smartphone/tablet. Bluetooth HC-05 module must be set to SLAVE mode otherwise your Android device will not see it. If it doesn't see it go here for more details on how to go to AT comms mode - you will need to check wiring, upload sketch and type in Serial Monitor AT command “AT+ROLE=0" or “AT+ROLE0" depending on your Bluetooth module firmware. 
  24. When you have your smartphone/tablet paired with bluetooth module HC-05 or HC-06 open the Arduino Bluetooth RC Car application.
  25. You can see the red light on the left top corner. It means that your application is not connected to Bluetooth module. So you need to go to Options.
  26. Select Connect to car.
  27. Select the bluetooth module.
  28. Congrats, you can controll your 4WD smart robot car now.
  29. There is accelerometer control mode available too. Go to Options and select accelerometer control.
  30. You can control your 4WD smart robot car with your smartphone/tablet just tilting it. Do not need buttons to do it.
  31. That's it. There are other applications available on Google Play market. You can easily modify the sketch with letters to be send (assigned in these applications).
  32. Test the robot is running correctly or not. If motor turn on wrong direction - interchange power o/p of motor drive module. If sleep L298N motor drive module - check GND connection between Arduino controller and motor drive module.

Summary

We learnt how to connect different components and make Bluetooth controlled 4WD smart robot car. 

Library

  • SoftwareSerial library included in Arduino IDE.  The library has the following known limitations:If using multiple software serial ports, only one can receive data at a time.Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).Not all pins on the Leonardo and Micro support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).On Arduino or Genuino 101 the current maximum RX speed is 57600bpsOn Arduino or Genuino 101 RX doesn't work on Pin 13 The library has the following known limitations: If using multiple software serial ports, only one can receive data at a time;Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69);Not all pins on the Leonardo and Micro support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI);On Arduino or Genuino 101 the current maximum RX speed is 57600bps; On Arduino or Genuino 101 RX doesn't work on Pin 13. You can read about it here.

Sketch

  • See attachments on the begining of this project


Other projects of Acoptex.com
Easy Raspberry basics: Project 26a Raspberry PI Zero W board - Enable SSH of Acoptex.com in Raspberry Pi Zero W 07-01-2019
Easy Raspberry basics: Project 24a Raspberry PI Zero W board - Apache web server of Acoptex.com in Raspberry Pi Zero W 05-01-2019

« Go back to category
Is this project fake? Report it!   
Recommend to a friend
Published at 03-04-2018
Viewed: 1050 times