The following is a test of OLED code:
# include "sys. H"
/* * * * * * * * * * * * * * * OLED IO interface * * * * * * * * * * * * * * * * * * * * * * * * * *
GND power to
VCC connect 5 v or 3.3 v power supply
SCL meet PB8 (SCL)
Meet PB9 SDA (SDA)
* * * * * * * * * * * * * * * * OLED IO interface * * * * * * * * * * * * * * * * * * * * * * * * * */
Int main (void)
{
Delay_init ();//=====time delay function initializes the
NVIC_Configuration ();//=====interrupt priority group
Uart1_init (128000);//=====serial port initialization 1
LED_Init ();//=====initialization IO
, which is connected with the LEDKEY_Init ();//=====button to initialize the
OLED_Init ();//=====OLED initialization
OLED_Clear ();//=====OLED screen clearing
While (1)
{
Delay_ms (50);//=====50 ms refresh screen at a time, do not need to have been refreshed,
OLED_ShowString (0, 4, "DAYUTC OLED Test", 12);
LED=~ LED;
}
}
The following is the code for the balance of the car (no response) after burn:
# include "sys. H"
# include "LED. H"
# include "nrf24l01. H"
# include "spi. H"
# define LED_ON GPIO_ResetBits (GPIOC, GPIO_Pin_13);
# define LED_OFF GPIO_SetBits (GPIOC, GPIO_Pin_13);
Float Voltage;//battery voltage sampling variables related to
Float pitch, roll and yaw;//euler Angle (attitude Angle)
Short aacx, aacy aacz;//acceleration sensor raw data
Short gyrox, gyroy gyroz;//gyroscope raw data
Float UltrasonicWave_Distance;//ultrasonic ranging
Int Encoder_Left Encoder_Right;//encoder pulse count
Int Moto1=0, Moto2=0;//calculate the final assigned to a PWM motor
Int Flag_Qian Flag_Hou, Flag_Left Flag_Right;//bluetooth remote control variables related to
U8 flag_UltrasonicWave=0;//whether the ultrasonic beyond a safe distance from mark a
U8 key=0;//button keys
U8 rx_buf [33].
Under-16 speed, rotate;
Signed char Count1, Count2;
Float pitch, roll and yaw;//euler Angle
Void RxHandle ()
{
If (NRF24L01_RxPacket (rx_buf)==0)//once received the information, are displayed.
{
Rx_buf [32]='\ 0';//add string terminator LED1_ON;
Memmove (& amp; Rotate, & amp; Rx_buf [6], 2);
Memmove (& amp; Pitch, & amp; Rx_buf [8], 4);
Memmove (& amp; Roll, & amp; Rx_buf [12], 4);
Memmove (& amp; Yaw, & amp; Rx_buf [16], 4);
If (rx_buf [2]=='1') Flag_Qian=1; The else Flag_Qian=0;
If (rx_buf [3]=='1') Flag_Hou=1; The else Flag_Hou=0;
If (rotate> 2500) Flag_Left=1; The else Flag_Left=0;
If (rotate<1500) Flag_Right=1; The else Flag_Right=0;
LED_ON;
Delay_ms (500);
LED_OFF.
Delay_ms (500);
}
}
Int main (void)
{
Delay_init ();//=====time delay function initializes the
NVIC_Configuration ();//=====the interrupt priority group, which contains all the interrupt priority level configuration, convenient management and one-time change,
NRF24L01_Init ();
NRF24L01_RX_Mode ();
Adc_Init ();//=====initialization ADC
Encoder_Init_TIM2 ();//2=====initialization encoder
Encoder_Init_TIM4 ();//=====initialization encoder 4
Timer3_Init (5000719);//=====ultrasonic timer initialization
LED_GPIO_Config ();
OLED_Init ();//=====OLED initialization
OLED_Clear ();//=====OLED screen clearing
MPU_Init ();//=====initialization MPU6050
Mpu_dmp_init ();//=====initialization MPU6050 DMP mode
UltrasonicWave_Configuration ();//=====initialization ultrasonic hardware I/o port
TIM1_PWM_Init (7199, 0);//=====initialization PWM 10 KHZ, used to drive motor,
Motor_Init ();//=====initialization and motor connection hardware I/o interface
MPU6050_EXTI_Init ();//=====MPU6050 5 ms timer interrupt initialization
Oled_first_show ();//need to display a character, only in a can, this refresh
While (NRF24L01_Check ())//testing NRF24L01 the existence
{
LED_ON;
delay_ms(200);
LED_OFF.
delay_ms(200);
} NRF24L01_RX_Mode ();
RxHandle ();
While (1)
{RxHandle ();
Oled_show ();
Delay_ms (50);//20 hz display frequency, the screen without time refresh,
}
}
CodePudding user response:
Please bosses predecessors and see what is wrong? Give the child anxious that bad,