8051單片機紅外線遙控實驗
![](http://editerupload.eepw.com.cn/fetch/20161101/323891_1_0.jpg)
![](http://editerupload.eepw.com.cn/fetch/20161101/323891_1_1.jpg)
如果網(wǎng)頁顯示格式錯亂可從這里下載完整的源程序:http://www.51hei.com/f/dpjjmhw.rar
//遙控器采用Ht6221芯片
//紅外線遙控 用外部中斷作為紅外線解碼輸入 紅外遙控器1號鍵為電風扇啟動鍵
#include
#define uchar unsigned char
#define uint unsigned int
code uchar seg[]={0x28,0x7e,0xa2,0x62,0x74,0x61,0x21,0x7a,0x20,0x60}; //數(shù)碼管碼表
code uchar tab[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe}; //數(shù)碼管位選
#define uint unsigned int
code uchar seg[]={0x28,0x7e,0xa2,0x62,0x74,0x61,0x21,0x7a,0x20,0x60}; //數(shù)碼管碼表
code uchar tab[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe}; //數(shù)碼管位選
code uchar ss[]={0x10,0x03,0x01,0x06,0x09,0x1d,0x1f,0x0d,0x19,0x1b,0x11,0x15,0x17,0x12,0x16,0x4c,0x40,0x48,0x04,0x00,
0x02,0x05,0x54,0x4d,0x0a,0x1e,0x0e,0x1a,0x1c,0x14,0x0f,0x0c}; //紅外線鍵碼1--32
0x02,0x05,0x54,0x4d,0x0a,0x1e,0x0e,0x1a,0x1c,0x14,0x0f,0x0c}; //紅外線鍵碼1--32
void delay(uint k)
{
while(k--);
}
{
while(k--);
}
void show(uint k) //顯示數(shù)值
{
uchar i=0,j;
uchar s[4]; //顯示最終位數(shù)
do
{
s[i++]=k%10; //數(shù)據(jù)分離
{
uchar i=0,j;
uchar s[4]; //顯示最終位數(shù)
do
{
s[i++]=k%10; //數(shù)據(jù)分離
}while(k/=10);
關(guān)鍵詞:
8051單片機紅外線遙
評論