# 1. Function description
1. Bluetooth control: Use the Bluetooth module to connect to the mobile phone, receive data, and realize the forward, backward, left, and right movement of the car and the speed adjustment function.
2. Battery capacity detection: The ADC function of the microcontroller collects the battery voltage and calculates the remaining battery power.
3. Five-channel infrared tracking: uses 5 infrared tubes to detect black lines on the ground and find path movements.
4. Ultrasonic obstacle avoidance: detect obstacles ahead through the ultrasonic module.
5. Buzzer alarm reminder: When an obstacle is detected or the battery is low, the buzzer will sound.
6. Independent button: can switch the car driving control mode.
~~7. WiFi control: Connect the mobile phone to the network through the WiFi module, and connect to the network to control the movement of the car. (Not implemented)~~
~~8. Camera: Display the camera image in real time. (Unimplemented)~~
# 2. The schematic
diagram is basically consistent with the official one, mainly because more stcs were used before. This is the first time for the Liangshan School to use 32-bit microcontrollers. There are also official tutorials for reference. , take this opportunity to study hard. Let’s talk about the main changes.
*
The original official use of the buck chip is the HE6250MPR LDO, but when used with lithium batteries, the microcontroller resets frequently. At first I thought of the problem of lithium batteries, because this chip supports up to 15V input, but the phenomenon was still the same after replacing it. I looked through the inventory and found 78m05, but the package was different. In desperation, I used The soul flying thread method finally solved the problem.
![image.png]

*
The main change in the Bluetooth module is that the original 3.3V power supply is changed to 5V, and a capacitor filter is added next to the power supply. I bought a module with a wide voltage base plate. The merchant said it had a 3.2~6V input, but it actually didn’t work when using 3.3V. It was a big mistake.
![image.png]

* Here in the tracking module
, I drew a separate circuit board. I wanted to compress the size within 10*10. I mainly implemented the traditional virtues of the Chinese nation-thrift. I definitely did not want to make a puzzle (dog head). The result In the end it didn't work out. Another purpose is to facilitate debugging, just use double pin row side welding.
![image.png]

# 3. Program
* The McClam wheel
principle is to use the particularity of the wheat wheel to change the different steering directions of the four wheels to achieve translation and tilt movement on the basis of ordinary wheels.
For details, please refer to the website: [McClam Wheel Principle](https://blog.csdn.net/weixin_64064747/article/details/128693337)
![C67I0JJ(C_CFL7XM0R{%Y.png]

```
/**** ************************************************
Function name: car_front
Function: Car forward
parameters: speed speed
return value: None
**************************************** *********/
void car_front(uint16_t speed)
{
motor_LQ_front(speed);
motor_LH_front(speed);
motor_RQ_front(speed);
motor_RH_front(speed);
}
/*********** *************************************
Function name: car_back
Function: Car retreat
Parameters: speed Speed
return Value: None
************************************************ **/
void car_back(uint16_t speed)
{
motor_LQ_back(speed);
motor_LH_back(speed);
motor_RQ_back(speed);
motor_RH_back(speed);
}
/****************** ******************************
Function name: car_left_run
Function: Move the car left
Parameters: speed Speed
return value: None
*** ************************************************/
void car_left_run( uint16_t speed)
{
motor_LQ_back(speed);
motor_LH_front(speed);
motor_RQ_front(speed);
motor_RH_back(speed);
}
/************************ ************************
Function name: car_right_run
Function: Move the car right
Parameters: speed Speed
return value: None
************ ****************************************/
void car_right_run(uint16_t speed)
{
motor_LQ_front( speed);
motor_LH_back(speed);
motor_RQ_back(speed);
motor_RH_front(speed);
}
/******************************************* *****
Function name: car_left
Function: Car turns left on the spot
Parameters: speed Speed
return value: None
****************************** *************************/
void car_left(uint16_t speed)
{
motor_LQ_back(speed);
motor_LH_back(speed);
motor_RQ_front(speed);
motor_RH_front(speed) ;
}
/*********************************************** *
Function name: car_right
Function: Car turns right on the spot
Parameters: speed Speed
return value: None
****************************** *******************/
void car_right(uint16_t speed)
{
motor_LQ_front(speed);
motor_LH_front(speed);
motor_RQ_back(speed);
motor_RH_back(speed);
}
/* *************************************************
Function name: car_left_front
function: car left front
parameter: speed speed
return value: None
**************************************** ************/
void car_left_front(uint16_t speed)
{
motor_LQ_front(1);
motor_LH_front(speed);
motor_RQ_front(speed);
motor_RH_front(1);
}
/******** ******************************************
Function name: car_right_front
function: Car right front
parameters: speed speed
return value: None
************************************************ *****/
void car_right_front(uint16_t speed)
{
motor_LQ_front(speed);
motor_LH_front(1);
motor_RQ_front(1);
motor_RH_front(speed);
}
/**************** *********************************
Function name: car_left_back
Function: Car left rear
parameter: speed Speed
return value: None
*************************************************/
void car_left_back(uint16_t speed)
{
motor_LQ_back(speed);
motor_LH_back(1);
motor_RQ_back(1);
motor_RH_back(speed);
}
/********************** ***************************
Function name: car_right_back
Function: Car right rear
parameter: speed Speed
return value: None
****** *****************************************/
void car_right_back(uint16_t speed)
{
motor_LQ_back(1);
motor_LH_back(speed);
motor_RQ_back(speed);
motor_RH_back(1);
}
``
Truth table↓
![4%49BW)S6U~VE9J9F0DDB1B.png]

# 4. Others
* Wheat wheel coupling My wheat wheel
and motor were bought on Taobao, but I couldn’t find a suitable coupling after searching for a long time, so I simply drew one myself, then 3D printed it, and put the file below.
If you are making a small amount of proofs, I have compared several manufacturers online and found that printing in our 3D Monkey is more cost-effective.
![image.png]

*
There are still many areas for improvement. For example, when placing the motor, the length of the reduction gearbox was not considered, which resulted in the final car being bloated and not in line with my original vision.
In addition, the power supply filtering was not sufficient this time, and many modules did not have capacitors. It can also have a built-in lithium battery charging circuit, so there is no need to plug and unplug the battery back and forth.