## 1. Overall introduction
### Front! [Screenshot 2023-05-31 092624.png]

* There is a Liangshan School interface on the front of the car, and a 3.7V battery at the bottom.
* There is an ultrasonic obstacle avoidance 4pin plug in the front, and the IP5306 boost charging module designed by myself in the lower left corner is used to charge and discharge the battery.
* A boat switch and two patch buttons on the left are used to switch modes and start and stop the car.
* The upper part is the adjustable resistor and LED light of the car's obstacle avoidance module!
* The right side is the buzzer and the 1.54-inch ink screen FPC interface, which uses SPI communication, and the middle is the Liangshan School double-row pin header
### Back! [Screenshot 2023-05-31 092746.png]

* There are four motor interfaces on the back of the car,
* A 5mm pitch connector is used,
* There are also motor driver chip l9110s and infrared obstacle avoidance module part at the bottom
* , the motor is not marked in the figure. The actual object will use four N20 reduction motors bonded to the PCB board by AB glue ###
Actual object![微信图片_20230531095350.jpg]

* ![微信图片_20230531095356.jpg]

* The actual object is shown in the figure above
* The hardware introduction is completed, and the software is introduced next
* First look at the requirements as shown in the figure
## 2. Pin assignment
### 1. Button * KEY0--》PB5 * KEY1--》PE5 * KEY0 is the start and pause button * KEY1 is the mode switch button ### 2. LED * LEDL--》PA12 * LEDR--》PG7 * LEDKEY0--》PB3 * LEDKEY1--》PE2 * LEDL is the left turn signal * LEDR is the right turn signal * LEDKEY0 is the KEY0 button indicator * LEDKEY1 is the KEY1 button indicator ### 3. USART0 * TX--》PA9 * RX--》PA10 * USART0 is the debug print serial port ### 4. Buzzer * BEEP--》PF8 ### 5. adc battery voltage acquisition * ADC--》PC5 ### 6. Motor drive * Left front * PB4 PA7 * Left rear * PB0 PB1 * Right rear * PA0 PA1 * Right front * PA3 PA2 ### 7. Infrared tracking * Left one--》PA15 * Left two--》PC10 * Left three--》PC12 * Left four--》PB13 * Left five--》PB15 ### 8. Ultrasonic * TRIG--》PB12 * ECHO--》PB10 ### 9. Bluetooth * u6TX--》PF7 * u6RX--》PF8 * ENABLE --》PF10 * STATE--》PF9 ### 10. spi ink screen * CS--》PE6 * SDI--》PC13 * SCLK--》PE2 * D/C--》PE5 * BUSY--》PG11 * RES--》PG13 ## 3. Component selection and schematic design ### 1. Battery charge and discharge management and boost module * ![image.png] * Adopt ip5306 integrated charge and discharge chip to achieve 3.7v input and 5v output, and with lithium battery charging protection, the design has a reference datasheet * ![image.png] ### 2. Buzzer module * ![image.png] * Adopt npn transistor to drive active buzzer to achieve alarm effect ### 3. Motor drive circuit * ![image.png] * The motor drive adopts l9110s, which has low voltage drive capability, can be powered by 5v voltage, and use high and low levels to control forward and reverse rotation * ![image.png] ## 4. PCBLAYOUT ### 1. Power and switch button part * ![image.png] * The power supply part is on the side, which is conducive to heat dissipation and reducing interference to the circuit. The 5v power line uses a thickened 20mil line, and copper coating is conducive to heat dissipation and anti-interference * The switch uses a boat-type switch, which can pass large current ### 2. Buzzer and screen FPC interface part * ![image.png] * Avoid right-angle routing for the screen interface, and the buzzer is plug-in ### 3. Infrared tracking module * ![image.png] * The infrared tracking is located on the back of the pcb, and the adjustable resistor is located on the front for easy adjustment * ![image.png] ## 5. Software and task display ### Task 1: * Press the button to control the led reverse toggle, and require 1 and 2 points to complete, see video 1 * Remote control to control the buzzer to sound, and require 3 points to complete, see video 2 ### Task 2: * The car adc collects voltage. The car uses a single 3.7v lithium battery. The real-time collected voltage is converted by adc and printed through the serial port. For details, see video 3. The serial port assistant in the video is the battery voltage of the car









* The car is driven by PWM. This car uses left and right turns to control the speed and turns. PWM is used to control the wheel speed. For details, see the rear remote control in video 2
### Task 3:
* The car mainly uses ultrasonic wave to measure the distance when avoiding obstacles. The ultrasonic wave can measure the distance to realize the prompt of too close distance. In video 3, the ultrasonic wave distance value is printed in the serial port assistant. It changes with the change of hand cover. It is obtained that when the distance is too close to the obstacle, the car will turn to avoid the obstacle.
* The tracking function of the car is mainly that black does not reflect infrared and white reflects. Five infrared modules are used to detect whether the black line is under the module. Five are judged separately. If 12345 is 1 0 0 0 1, it is within the line. If it is 0 0 0 1 1, it is biased to the right and can turn left. If it is 1 1 0 0 0, it is biased to the left and can turn right, so as to realize the line-finding function.
* The remote control function of the car is realized through the transparent transmission function of the Bluetooth module, and the remote control function is realized with the mobile phone app! [e72e8132925d7f598b14c257692a2bf.jpg]

* For details of the remote control, please see Video 2. The front, back, left, right, lights and buzzer of the car can be remotely controlled.
* All three tasks have been completed, and the functions of the car have been basically realized. Due to the short time near the end of the semester, the work is a bit rough. Thanks to Jia Li Chuang for providing the opportunity to make a free board, so that more electronics enthusiasts can like electronics.
* Finally, the code, video and debugging software are packaged in the attachment. See code.7z base.apk ~~~~~~