簡單遙控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)
2019-7-21 18:40 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|