单片机源程序如下:
- #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)
|