單片機源程序如下:
- #include "stm32f10x.h"
- #include "drive.h"
- #include "hongwai.h"
- #include "chaoshengbo.h"
- #include "timer.h"
- #include "delay.h"
- #include "stm32f10x_gpio.h"
- #include "usart.h"
- #include "stm32f10x_it.h"
- #include "duoji.h"
- #include "shengjiangtai.h"
- #include "led.h"
- #include "beep.h"
- #include "xianwei.h"
- int jsnum = 0;
- extern int hwflag;
- int main()
- {
-
- SystemInit();
- driveGPIO_Init();
- delay_init(); //延時初始化
- UltrasonicWave_Configuration(); //對超聲波模塊初始化
- uart_init(9600); //串口初始化
- NVIC_Configuration(); //設置優先級
- Timerx_Init(5000,7199); //10Khz的計數頻率,計數到5000為500ms
- TIM3_PWM_Init(899,0); //不分頻。PWM頻率=72000000/900=80Khz
- TIM3_PWM_Init2(899,0); //不分頻。PWM頻率=72000000/900=80Khz
- LED_Init(); //初始化與LED連接的硬件接口
- BEEP_Init(); //初始化蜂鳴器端口
- shengjiangtaiGPIO_Init(); //初始化升降臺
- duoji(0x23,0x31,0x32,0x47,0x43,0x31,0x0D,0x0A);
- while(1)
- {
- if (jsnum > 500 || hwflag == 1)
- {
- UltrasonicWave_StartMeasure();
- jsnum = 0;
- } //開始測距,發送一個>10us的脈沖,然后測量返回的高電平時間
- delay_ms(1);
- jsnum++;
- LED0=0;
- xunji();
- }
- }
復制代碼
所有資料51hei提供下載:
機械臂小車尋白線程序.rar
(296.38 KB, 下載次數: 21)
2017-11-2 20:29 上傳
點擊文件名下載附件
循跡
|