How to control robot with your phone using BLE?
A robot is a machine which responds to commands. These commands are programmed by the user to achieve a specific task. Robots are made by actuators, motors and sensors and a control system which contains a microcontroller. The robot we are going to make is a simple rover made by two DC motors which can go forward, backward, turn right or left by giving commands from a smartphone. The wireless technology we are using here is Bluetooth low energy (BLE) which comes integrated with the “seeed studio BLE sense†board. BLE consumes less power as compared to standard Bluetooth module HC-05. So lets get started with the project.
Components required
- NRF52840 sense
- L293D motor driver
- Robot car chassis (with two DC motors)
- USB C type cable
- Jumper wires
- Battery holder of 4 cells
- AA batteries – 4pcs
Once we got all the necessary components along with proper robot chassis kit. Now we are ready to make the hardware connections. Connect the components according to below given circuit diagram.
Working of L293D motor driver
The L293D motor driver is the best option when it comes to controlling DC motors. It has integrated dual H-bridge. Using just one single driver we can control 2 motors. It has 4 outputs M1, M2, M3 and M4. One motor is connected to M1 and M2 and another is connected to M3 and M4. It also has 4 inputs to control the direction of motor IN1, IN2, IN3 and IN4. Giving HIGH to IN1 and LOW to IN2 causes the right wheel to move forward. In similar way if we reverse the order and give LOW to IN1 and HIGH to IN2 causes the right wheel to move backward. Same goes for controlling the left wheel just the inputs are IN3 and IN4.
Making the seeed studio boards compatible with Arduino IDE.
Before uploading the code we need to add the seeed studio boards compatible with Arduino IDE.
Step 1 - Copy the below given link.
https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json
Step 2 – Open Arduino IDE >> file >> preferences
Step 3- Paste the link in “Additional Boards Manager URL’sâ€. If there are other links then you can separate the links with comma. Then click on “okâ€. The boards are now added to the board manager.
Step 4- Open “board manager†and search for keyword “seeed nrf52â€. You will find two board libraries. Install both of them.
Now that all seeed studio boards are added to the Arduino IDE, we can select our board and upload program to it.
Adding the ArduinoBLE library
Step 1 – The library zip folder will be downloaded
Step2 – Go to sketch >> include library >> add .zip library. Then browse to the location where the zip folder is downloaded. Open the zip folder and the library will be installed.
The “ArduinoBLE.h†library is now installed. Now we can upload the code to the “seeed studio sense boardâ€.
Selecting the board and port before uploading.
Go to tools >> boards >> “Seeed nrf mbed enabled boards†>> select the “seeed xiao BLE sense†board.