Bluetooth App-Controlled Dual Motor Device
A device that can control 2 DC motors with Android smartphone/tablet + bluetooth controller app for a remote-controlled Arduino car. Uses L298N motor driver and HC-05 bluetooth module. Code available in Arduino IDE & mBlock 3 flavours.
Note - FOR MBLOCK 3 USERS:
If you are using mBlock 3 instead of Arduino IDE for coding, then you can download the mBlock 3 code for this device here. You will also need the 'Bluetooth HC-05 PCM' Extension (in mBlock 3, go to Extensions > Manage Extensions, search for 'PCM' and find and download 'Bluetooth HC-05 PCM') or else certain blocks will not be visible.
A screenshot of the mBlock 3 code (or what you should see on your screen if you load the extension correctly) can be viewed here.
For this project, you will need the following:
- 1 x Arduino UNO R3 (or compatible) Board
- 1 x L298N Motor Driver (jumper caps MUST be on 'ENA' and 'ENB')
- 2 x Arduino DC Motor
- 1 x HC-05 Bluetooth Module
- 1 x 7.4v (not 3.7v) Lithium Battery
- 1 x Android Smartphone/Tablet w/Arduino Bluetooth Controller (SA Tech) App
- 1 x Barrel Wire Jack Adapter (Female) - OPTIONAL
Follow the component diagram and wire-up your components accordingly. NOTE: If your 7.4v lithium battery has a male barrel wire jack instead of separate positive + negative wires, then you will need to connect a respective female barrel wire jack to +12V (positive) and GND (negative) of the L298N Motor Driver.
Arduino IDE code is here.
mBlock 3 code is here.
PRIOR TO UPLOADING CODE: Once you have wired up your device and plugged the Arduino board into your computer, you must ensure you remove the jump wire from Digital Port 0 (RX) or the code will refuse to upload to the board. Once you have completed the upload then you may connect the jump wire back to Digital Port 0 (RX).
Once you download and run the Arduino Bluetooth Controller (SA Tech) App from your Android smartphone/tablet, ensure your dual motor device is on (via. battery connected directly to L298N and NOT to the UNO R3 board) and pair your smartphone/tablet's bluetooth with the HC-05 module (usually named by default as 'HC-05' with password '1234'). Once paired, load the 'Terminal' component of the app.
The HC-05 bluetooth module and code work through serial communication (i.e. sending characters/data back-and-forth), thus certain characters received by the HC-05 correspond to a particular motor direction (as per. code).
Therefore, try entering the following characters/numbers into the terminal to manipulate motor movement:
1 = Left Motor Forwards
2 = Left Motor Backwards
3 = Right Motor Forwards
4 = Right Motor Backwards
5 = Left Motor Forwards, Right Motor Backwards
6 = Left Motor Backwards, Right Motor Forwards
7 = BOTH Motors Forward
8 = BOTH Motors Backward
0 = BOTH Motors OFF
Note: Motor speed is constant and cannot be changed.
As the dual motor device is for a remote-controlled car, it is advisable to control the device with the 'Remote Controller' part of the app, but you will have to map the correct characters/numbers with the correct respective button (e.g. UP arrow is 7, DOWN arrow is 8 and so forth), and once you have done it correctly you'll have a fully-functional remote controller via. smartphone/tablet.