stm32驱动光电传感器源程序分享
全部资料下载地址:
核心板程序7.31.rar
(304.19 KB, 下载次数: 92)
- #include "led.h"
- #include "delay.h"
- #include "exti.h"
- #include "PWM.h"
- #include "oled.h"
- #include "encoder.h"
- #include "timer.h"
- #include "adc.h"
- #include"light.h"
- #include "usart.h"
- int Encoder;
- int a,b,c;
- float angle = 0.0;
- extern u8 TIM2CH1_CAPTURE_STA; //输入捕获状态
- extern u16 TIM2CH1_CAPTURE_VAL; //输入捕获值
- void show(void);
- void sys_init(void)
- {
- LED_Init();
- delay_init();
- uart_init(9600);
- //Encoder_Init_TIM2();
- //TIM1_Int_Init(49,7199);
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
- EXTIX_Init();
- TIM3_Cap_Init(9999,719);
- motor_init();
- //TIM_PWM_Init(7199,0);
- //Adc_Init();
- OLED_Init();
- LED1 = 0;
- delay_ms(500);
- LED0 = 0;
- }
- int main()
- {u8 t=0;
- u8 len;
- u16 times=0;
- sys_init();
- delay_ms(10);
- while(1)
- {
- if(t==255)
- {t=0;}
- USART_SendData(USART1,t);
- delay_ms(1);
- t++;
-
- }
-
-
- }
- void show(void)
- {
- OLED_ShowString(0,0,"LZR0111"); //OLED_ShowNumber(95,50,Encoder,5,12); //测量位置 默认10000
- OLED_ShowNumber(0,10,Encoder,5,12);
- OLED_ShowNumber(0,20,angle/4095 * 360,5,12);
- OLED_ShowNumber(0,30,a,5,12);
- OLED_ShowNumber(0,40,b,5,12);
- OLED_ShowNumber(0,50,c,5,12);
- OLED_Refresh_Gram(); //===刷新
- }
复制代码
|