A smart car with Bluetooth remote control and autonomous obstacle avoidance based on GD32 main control.
The car uses the Lichuang Liangshan School development board GD32F470ZGT6 as the main control. It can realize tracking, Bluetooth remote control, ultrasonic obstacle avoidance, button control to switch the car's motion mode and other functions. , because it is the first time to draw a PCB board, there is no expansion I/O reserved, there are many welding problems and my own assembly experience is insufficient, the motor drive in the video is not sensitive.
## Physical display
! [QQ picture 20230221082642.jpg]

## Looking down
! [IMG_20230221_082511.jpg]

## Looking up
! [IMG_20230221_082403.jpg]

# Circuit part
## Power circuit (two 3.7V No. 5 14500 lithium batteries)
two cells The 3.7V lithium battery provides 7.4V voltage, and the voltage stabilizing module outputs 5V to supply peripheral circuits such as main control and tracking circuits. It is worth mentioning that the addition of two 100uF capacitors can effectively reduce the impact of voltage fluctuations on the circuit. It is very common in power supply circuits. The function of the capacitor in the C51 crystal oscillator circuit is mainly to achieve a phase delay of 180°, which is the same as the inversion. It is matched with a device to produce sinusoidal oscillation at both ends of the circuit. It works differently here.
![2023-02-21 08 31 31.png]

## Tracking circuit
The tracking circuit can be seen as two parts. The infrared pair tube generates high and low levels, the LM393 comparator compares them, and the reference standard and sliding The resistance of the rheostat is related, so sliding the rheostat can adjust the sensitivity of the module.
The LM393 here is often used as a CMOS and TTL driving component, which is very useful for debugging optoelectronic instruments.
![Tracking circuit.png]

## Buzzer circuit
(if the voltage is high, the buzzer will always beep at a low volume, you can replace the 1k resistor with a 10K resistor)
![Buzzer circuit.png ]

## Motor drive circuit
Personally, I think the focus is on the use and debugging of the truth table. During the previous debugging process, it was discovered that if the PWM is directly modulated, although the reduction motor can respond quickly, the large inertia will cause great wear and tear on the structure of the motor itself, especially the gear. Therefore, in the "software design focus", every time the steering is changed, the speed is decreased and increased step by step to alleviate damage to the structure.
![Motor drive circuit.png]

## Ultrasonic module circuit (ultrasonic module can be purchased directly)
![Ultrasonic circuit.png]

## Bluetooth module circuit (Bluetooth module can also be purchased directly)
![Bluetooth module.png]

# Software design Key part```
//
Speed increases
while(speed <= speedT)
{
car_back(speed);
speed++;
delay_1ms(1);
}
delay_1ms(300);
// Speed decreases
while(speed > 0)
{
car_back(speed) ;
speed--;
delay_1ms(1);
}
```
# Project summary
1. Before drawing the board, you need to do the following: roughly select the equipment, allocate the main control I/O, familiarize yourself with the device data manual and preliminary calculation of the physical parameters of each part. , schematic drawing.
2. Pay more attention to algorithms in the next project and properly encapsulate functions to avoid code redundancy.
3. Consider introducing a DSP library for matrix operations.
4. The temperature should be adjusted before welding to ensure that the solder can adhere to the welding gun. Completing a soldering operation means scraping the solder once.