### Use Liangshan School to make a smart car
#### Mainly has the following functions
* Tracking function-to achieve the effect of black line tracking
* Obstacle avoidance function-to bypass or avoid collision with obstacles
* 2.4G/Bluetooth/WIFI Remote control - realize the effect of remote control of the car
* N20 motor drive - drive the N20 motor to control the movement of the car
* LED car lights, buttons, buzzer, ADC voltage collection
#### Specific plan
* **Tracking function plan**
* Use [ITR9909](https://item.szlcsc.com/54415.html) Infrared pair tube and LM393 voltage comparator, the voltage comparator outputs to the microcontroller I/O, when the voltage comparator outputs high level, the infrared light is absorbed , the black line is detected, the LED light turns on, and the microcontroller I/O reads a high level. According to the status of the 5 I/Os, the next step of the car's travel direction is judged, and the N20 motor is controlled to go straight or turn.
![Tracking circuit]
* **Ultrasonic obstacle avoidance function solution**
* Using the ultrasonic obstacle avoidance module HC-SR04, the microcontroller I/O sends a signal, the HC-SR04 module emits ultrasonic waves, and the microcontroller starts timing. When the ultrasonic wave encounters an obstacle After receiving the echo, the HC-SR04 module sends a high level to the I/O of the microcontroller. The microcontroller stops timing and calculates the obstacle distance based on the time difference.
![HC-SR04]
![3.jpg]
* **Motor Driver**
* Use [BDR6122T](https://item.szlcsc.com/769387.html) motor driver chip to drive the N20 motor. It is connected to the chip IN1 IN2 pin through the IO port, and outputs PWM to control the speed and high and low level control. Forward, backward, stop.
![4.png]
![5.png]
* **2.4G/Bluetooth/WIFI remote control function solution**
* 2.4G adopts [M-BK2461U](https://item.szlcsc. com/3006940.html) module is controlled through the serial port
* Bluetooth uses the HC05 module based on the SPP protocol to control the car
* WIFI uses ESP32C3 to connect to the Liangshanpai development board through the serial port, open the WEB service on the ESP32C3, and transfer data through websocket to control the car.
![7 .png]
![6.png]
* **Other functions**
* The LED car light is connected to the microcontroller IO, and the LED light is controlled through the high and low levels of the microcontroller IO
![8.png]
* One end of the button is connected to the microcontroller IO port. The other end is connected to ground, and the button status is obtained by reading the high and low levels
* The buzzer uses [TMB12A03](https://item.szlcsc.com/834375.html) active buzzer, using SS8550 as a switch, through the IO port High and low level control sound
! [9.png]
* ADC voltage collection uses three 10K resistors to divide the voltage, and calculates the current voltage based on the 12-bit ADC value obtained from the IO port and the preset highest and lowest voltages
! [10.png ]
* The power supply adopts [ME78M05](https://item.szlcsc.com/85137.html) LDO chip to realize 2S battery conversion to 5V power supply
! [11.png]
* The DCDC power supply method is reserved in the "Fengwei" part, It can have higher efficiency and lower heat
! [12.png]
#### Actual object
* The shape of the car is imitating the shape of the Tamiya FMA-CHASSIS chassis
* The tracking circuit imitates the "dragon head and phoenix tail" shape of the four-wheel drive vehicle
* "Phoenix The tail "expands the DCDC circuit, which is more efficient and generates less heat than LDO
! [Chassis]
! [Liangshan School]