19參加江蘇省機器人大賽獲得一等獎該程序部分包括內容有:
1.車道兩邊有擋板,利用超聲波模塊測量距離兩邊的距離,以此達到車道保持的效果。
2.利用激光測距模塊測量與前車的距離,當距離小于200mm時轉向超車。
3.利用灰度模塊檢查地面的菱形標志
4.利用紅外管檢查是否到達人行橫道線并停車,
主控板是STM32C8T6
底盤部分包括2個驅動電機+1個轉向電機,由平衡小車之家購買。
激光測距模塊/紅外/超聲波/灰度模塊可在正點原子官網買到。
單片機源程序如下:
- #include "delay.h"
- #include "key.h"
- #include "sys.h"
- #include "lcd.h"
- #include "usart.h"
- #include "24cxx.h"
- #include "vl53l0x.h"
- #include "dianji.h"
- #include "timer.h"
- #include "huidu.h"
- #include "led.h"
- #include "vl53l0x_gen.h"
- #include "Ultrasonic.h"
- int main(void)
- { delay_init(); //延時函數初始化
- delay_init();
- //uart_init2(115200);
- uart_init2(115200);
- TIM2_time_init(6999,719); //70ms
- Ultrasonic_IO_Init();
- Start_hc_sr04();
- NVIC_Configuration();
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//設置中斷優先級分組為組2:2位搶占優先級,2位響應優先級
- Led_Init();
- TIM4_PWM_Init(19999,71);
- TIM_SetCompare4(TIM4, 18500);
- TIM3_PWM_Init(7199,0);
- Dianji_Init();
- TIM_SetCompare3(TIM3, 2800);//電機A占空比
- TIM_SetCompare4(TIM3, 2800);//電機B占空
- Huidu_Init();
- HongWai_Init();
- AT24CXX_Init();
- while(AT24CXX_Check())//檢測不到24c02
- {
-
- Led_Red=!Led_Red;//
- delay_ms(200);
- }
- //while(1)
- //{
- // GPIO_SetBits(GPIOC,GPIO_Pin_13);
- // delay_ms(200);
- // GPIO_ResetBits(GPIOC,GPIO_Pin_13);
- // delay_ms(200);
- //}
- Read_data();
- tingzhi();
- // while(1)
- // {
- // u8 flag = 0;
- // flag = Read_data();
- // if(flag)
- // {
- //
- //
- // GPIO_SetBits(GPIOC,GPIO_Pin_13);
- // delay_ms(200);
- // GPIO_ResetBits(GPIOC,GPIO_Pin_13);
- // delay_ms(200);
- //
- // }
- // }
- while(1)
- {
- // zhixing();
- vl53l0x_test();//vl53l0x測試
- }
- }
復制代碼
所有資料51hei提供下載:
錐形標.7z
(314.28 KB, 下載次數: 37)
2020-4-20 00:02 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
在這里將源碼公布
|