The functions
are mainly divided into the following modules :
power module,
motor drive module ;
OLED module
, tracking module;
LED display module;
buzzer module;
button module;
Bluetooth module;
power detection module;
ultrasonic module;
1. Power module
The power module is powered by two 14500 batteries. The input voltage is about 8V. First, it passes through the SS34 module to prevent the power from flipping,
and then the voltage is stabilized to 5V through the SSP7603P50PR module, and then the 5V is supplied to the Liangshanpai development board and other modules.
2. Motor drive module
This module uses four RZ7889 chips to drive four N20 motors. Each chip inputs two PWM signals and outputs two signals to drive the N20 motors. It is powered by the circuit through the SS34 module
without passing through the step-down chip .
3. OLED module
This module is a 0.96-inch monochrome OLED screen, which is used to display various information such as power, ultrasonic distance measurement, etc. It is powered by 3.3V.

4. Tracking module
This module uses five ITR9909 modules to detect black lines. When a black line is detected, the LED above will light up, otherwise it will not light up;
the five modules are evenly arranged in the middle of the vehicle, and the middle ITR9909 module is placed in the middle of the vehicle. When the vehicle is detected to be biased to the left, the vehicle is controlled to turn right;
when the vehicle is detected to be biased to the right, the vehicle is controlled to turn left, so as to realize the tracking function.

5.LED display module
This module uses two light-emitting diodes as the left and right lights of the smart car, and two light-emitting diodes as indicator lights.

6. Buzzer module
This module uses a TMB12A05_C96093 module for sound prompts. When the battery is low, a sound prompt will be issued.
7.Key module
This module uses two keys for mode switching and other functions. Use the interrupt capture pin to switch functions.
8.Bluetooth module
Here mainly uses the HC-04 Bluetooth module for remote control with the mobile phone App.
9.Power detection module;
these two mainly use the ADC input detection function of the microcontroller pin, use three 10K resistors to divide the input voltage of the battery, and input the voltage after the voltage division
to the ADC detection pin, and the power level is obtained according to the ADC value.

10.Ultrasonic module
Here uses the HC-SR04 module. The ultrasonic wave is installed at the front of the vehicle to detect the distance between the obstacle in front and the vehicle. When the distance of the obstacle is less than
a certain threshold, the vehicle stops to avoid collision.
PCB LayoutIn
order to save space, the buzzer is placed at the bottom, which does not affect the overall function.
The four motors are placed under the PCB board.
Important code descriptionIn
the while loop, switch case is used to parse the serial port data to achieve different functions. The key code is as follows:
/* Wait for data transmission to be completed*/
if(g_recv_complete_flag) // Data reception completed
{
g_recv_complete_flag = 0; // Wait for the next receptionprintf
("g_recv_length:%d ",g_recv_length); // Print the length of the received dataprintf
("g_recv_buff:%s
",g_recv_buff);// Print the received dataswitch
(g_recv_buff[0]){
case 1:
car_front(speed);//Forwardprintf
("car_front
");
break;
case 2:
car_back(speed);//Backwardprintf
("car_back
");
break;
case 3:
car_left(speed);//Turn
leftprintf("car_left
");
break;
case 4:
car_right(speed); //Turn right
printf(" car_right
");
break;
case 5:
car_stop(); //Stop
printf("car_stop
");
break;
case 6:
LED_L_on();
LED_R_on();
printf("LED on
");
break;
case 7:
LED_L_off();
LED_R_off();
printf("LED off
");
break;
case 8:
speed=6 0;//Slow
printf("speed=50;
");
break;
case 9:
speed=80;//Medium speed
printf("speed=60;
");
break;
case 10:
speed=100;//Fast
printf( "speed=100;
");
break;
default:
printf("Command error!!!
");
break;
}
memset(g_recv_buff,0,g_recv_length);// Clear array
g_recv_length = 0;// Clear length
} // if Most of
the materials are
purchased in LiChuang Mall, N20 motor and battery are purchased in Taobao;
Battery purchase link: Battery purchase link;
N20 motor, in addition to the motor, there are wheels, battery box, and motor seat are all bought in this store;
Ultrasonic, Bluetooth and OLED screens are previous stocks
Actual pictures
Picture 1
Picture 2