πŸ“œ ⬆️ ⬇️

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
MotorsMotor Shield L293DHeadlightsArduino Mega 2560
P.L.M3P.L.β€œ-” on GND, β€œ+” on Pin 22
P.P.M4P.P.β€œ-” on GND, β€œ+” on Pin 24
Z.L.M1Z.L.β€œ-” on GND, β€œ+” on Pin 34
Z.P.M2Z.P.β€œ-” on GND, β€œ+” on Pin 35
Range finder HC-SR04Arduino Mega 2560Bluetooth HC-05Arduino Mega 2560BuzzerArduino Mega 2560
Vcc5VVCC5VSigPin A9
TrigPin 31GNDGNDVCCPin A8
EchoPin 30TxdPin 50GNDGND
GndGNDRxdPin 51
MG995 servo driveMotor Shield L293D
Triple ClemSERVO_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

Source: https://habr.com/ru/post/373153/


All Articles