简单遥控led亮灭 也可用作继电器的控制
可通过键值判断所按的是哪个按键
单片机源程序如下:
- #include "stm32f10x.h"
- #include "oled.h"
- #include "delay.h"
- #include "exti.h"
- #include "key.h"
- #include "led.h"
- #include "ultrasonic.h"
- #include "capture.h"
- #include "remote.h"
- //如果加按键要注意A0口 已经有了定义
- float temp=3.3;
- unsigned char flag=0;
- unsigned char Num[10]={0,1,2,3,4,5,6,7,8,9};
- int main(void)
- {
- u8 key;
- u8 t=0;
- u8 *str=0;
- delay_init(); //延时函数初始?
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);// 设置中断优先级分组2
- //uart_init(9600); //串口初始化为9600
- OLED_Init();
- Remote_Init(); //红外接收初始化
- LED_Init();
-
- while(1)
- {
- key=Remote_Scan();
- if(key)
- {
- Dis_Num(4,6,key,2);//Dis_Float(4,71,key,2);// LCD_ShowNum(116,130,key,3,16); //显示键值
- Dis_Num(4,2,RmtCnt,2);// LCD_ShowNum(116,150,RmtCnt,3,16); //显示按键次数
- switch(key)
- {
- case 162: LED0 =!LED0; break;
-
- case 98: LED0 =!LED0; break;
-
- }
-
- }else
- delay_ms(10);
-
- }
- }
-
复制代码
所有资料51hei提供下载:
红外遥控+继电器.7z
(197.56 KB, 下载次数: 35)
|