Robot mobile based on Arduino Mega 2560 with Bluetooth control and autonomous movement with obstacles bypass
I present my project on the Arduino roboMobile. On the Internet there are a lot of similar articles, stumbled upon one of them decided to implement what he saw with his changes in the design and functionality. The following features have been implemented: control of the mobile car via Bluetooth from a smartphone; Autonomous movement of a mobile with a detour of obstacles.
For the implementation we need: ')
Set: frame, motors, wheels, mounts (Car Chassis Kit for Arduino - photo ) Arduino Mega 2560 Motor Control Shield for Arduino L293D MG995 servo drive Ultrasonic Range Finder HC-SR04 Bluetooth module HC-05 JY-MCU Active High Level Alarm / Speaker Buzzer Module Headlight Diodes Connecting wires Holders for the rangefinder and Bluetooth module (I did it myself) Power supply (I took from the cash register) Android application to control the robil mobile via Bluetooth Arduino Bluetooth RC Car ( photo , when connected to the Bluetooth module, the default pin code is β1234β)
Connection of components
Motors
Motor Shield L293D
Headlights
Arduino Mega 2560
P.L.
M3
P.L.
β-β on GND, β+β on Pin 22
P.P.
M4
P.P.
β-β on GND, β+β on Pin 24
Z.L.
M1
Z.L.
β-β on GND, β+β on Pin 34
Z.P.
M2
Z.P.
β-β on GND, β+β on Pin 35
Range finder HC-SR04
Arduino Mega 2560
Bluetooth HC-05
Arduino Mega 2560
Buzzer
Arduino Mega 2560
Vcc
5V
VCC
5V
Sig
Pin A9
Trig
Pin 31
GND
GND
VCC
Pin A8
Echo
Pin 30
Txd
Pin 50
GND
GND
Gnd
GND
Rxd
Pin 51
MG995 servo drive
Motor Shield L293D
Triple Clem
SERVO_2 (central wire β+β is bite off and feed directly from β+β Motor Shield - photo ; when operating via Bluetooth - remove the terminal so that the server does not twitch)
Assembly process
We solder wires to motors, pay attention, on all lower contacts I have black wires, on the upper ones - red ones; do not confuse polarity when connected to Motor Shield.
Fasten the servo to the top of the frame, the motors to the bottom, assemble the frame, put the wheels. Install the Motor Shield on top of the Arduino Mega and fasten it to the frame, connect everything according to the scheme above, fill in the appropriate sketch (at the end of the article) - enjoy.
Bluetooth control - install the application on your smartphone, launch it, connect (Connect) to the Bluetooth module (enter the pin code if necessary); You can control the classic way by the arrows (Buttons), as well as in the program menu, you can select Accelerometer and control it using the tilts of the smartphone.
Autonomous movement with obstacles around - the algorithm is as follows: the range finder measures the distance ahead, if it is> 30 cm (in the sketch, the parameter is const int vmindistance), then we continue to move forward, if <30 cm, then: we stop the motors; twist the servo at angles from 0 Β° to 180 Β° in 15 Β° increments and measure the distances at these angles; enter the obtained values ββinto the array; turn the servo right at an angle of 90 Β°; look for the position in the array with the maximum data value; if this value is <30 cm, then we go back, if> 30 cm, then we check what angle of rotation of the servo drive it corresponds to and, depending on this, turn left or right.
Short video
Bluetooth control:
Autonomous traffic with obstacle avoidance:
Download links:
β AFMotor Library β Sketch - control via Bluetooth β Sketch - autonomous movement with a detour of obstacles β Manual for Bluetooth module HC-05