新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 8051單片機(jī)紅外線遙控實(shí)驗(yàn)

8051單片機(jī)紅外線遙控實(shí)驗(yàn)

作者: 時(shí)間:2016-11-30 來(lái)源:網(wǎng)絡(luò) 收藏

如果網(wǎng)頁(yè)顯示格式錯(cuò)亂可從這里下載完整的源程序:http://www.51hei.com/f/dpjjmhw.rar
//遙控器采用Ht6221芯片
//紅外線遙控 用外部中斷作為紅外線解碼輸入 紅外遙控器1號(hào)鍵為電風(fēng)扇啟動(dòng)鍵
#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ù)碼管位選
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
void delay(uint k)
{
while(k--);
}
void show(uint k) //顯示數(shù)值
{
uchar i=0,j;
uchar s[4]; //顯示最終位數(shù)
do
{
s[i++]=k%10; //數(shù)據(jù)分離
}while(k/=10);
for(j=0;j {
P0=seg[s[j]];
P2=~(1<<(3-j));
delay(100);
P0=0xff;
P2=0xff;
}

}
上一頁(yè) 1 2 下一頁(yè)

關(guān)鍵詞: 8051單片機(jī)紅外線遙

評(píng)論


技術(shù)專區(qū)

關(guān)閉