這是一套完整的stm32f103的平衡車程序,大家可以參考一下
單片機源程序如下:
- #include "delay.h"
- #include "sys.h"
- #include "usart.h"
- #include "led.h"
- #include "bluetooth.h"
- #include "motor.h"
- #include "speed.h"
- #include "mp6050.h"
- #include "key.h"
- #include "ultrasonic.h"
- #include "DataScope_DP.h"
-
-
- int main(void)
- {
- u8 i,Send_Count;
-
- delay_init(72);
- NVIC_Configuration();
- uart_init(9600);
- LED_Init();
- KEY_Init();
- BLUETOOTH_Init(9600);
- MPU6050_Init();
- PID_Init();
- ENCODER_Init();
- ULTRASONIC_Init();
- MOTOR_Init();
- while (1)
- {
- // DataScope_Get_Channel_Data( acc_x, 1 ); //上位機波形顯示
- // DataScope_Get_Channel_Data( gyro_y, 2 );
- // DataScope_Get_Channel_Data( angle_ax, 3 );
- // DataScope_Get_Channel_Data( angle_gy , 4 );
- // DataScope_Get_Channel_Data(angle, 5 );
- // DataScope_Get_Channel_Data(Kp , 6 );
- // DataScope_Get_Channel_Data(speed, 7 );
- // DataScope_Get_Channel_Data( 0, 8 );
- // DataScope_Get_Channel_Data(0, 9 );
- // DataScope_Get_Channel_Data( 0 , 10);
- // Send_Count = DataScope_Data_Generate(10);
- // for( i = 0 ; i < Send_Count; i++)
- // {
- // while((USART1->SR&0X40)==0);
- // USART1->DR = DataScope_OutPut_Buffer[i];
- // }
- // delay_ms(50); //20HZ
-
-
- ULTRASONIC_Distance();//600ms測距一次
- //USART_ITConfig(USART3, USART_IT_TXE, ENABLE);//使能USART3發送中斷
- delay_ms(600);
- }
- }
復制代碼
所有資料51hei提供下載:
平衡車.rar
(331.46 KB, 下載次數: 233)
2018-9-14 17:58 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|