单片机课程设计
void irpros() { uchar k,i,j; k=1; uchar value; //红外处理函数,(提取)处理客户码那4个字节 for(j=0;j<4;j++) //执行完这个循环后就提取完四个个字节 { for(i=0;i<8;i++) //执行完这个循环后就提取完一个字节的数据了 { value=value>>1; if(irdata[k]>6) //判断数据是0还是1,如果是0的话就会用时1.125/0.256约等于4.4,如果是数据1传输就会用时2.25/0.256约等于8.8,,所以当此数值大于6时则为数据1,小于6则为数据0 } void main() { chushihua_595(); init(); while(1) { if(irreceok) //判断红外接收是否OK { } { } irwork(); irprosok=0; irpros(); //提取那四个字节的数据 irreceok=0; key(); } irprosok=1; } ircode[j]=value; { } k++; value=value|0x80; if(irprosok) //判断是否提取完那几个字节的数据 ,若提取完,则转换 25
单片机课程设计
} } void timer0() interrupt 1 { } void int0() interrupt 0 { if(startflag) { //判断是否是引导码,引导码一共用时9ms左右
irtime++; //红外时间 255之后就会溢出,重新幅值0; if(irtime>32) 9ms/0.256=33.15 } void key() {
{ } irdata[bitnum]=irtime; irtime=0; bitnum++; if(bitnum==33) { } else { startflag=1; irtime=0; } //按键功能函数 //电源 } bitnum=0; irreceok=1; bitnum=0; if(ircode[2]==0x45) { } displed(0); else if(ircode[2]==0x47) //memu { 26
单片机课程设计
} displed(16); else if(ircode[2]==0x44) //TEST { } else if(ircode[2]==0x40) //+ { displed(48); } else if(ircode[2]==0x43) //返回 { displed(64); } else if(ircode[2]==0x07) //上一首 { displed(80); } else if(ircode[2]==0x15) //播放 { displed(96); } else if(ircode[2]==0x09) //下一首 { } else if(ircode[2]==0x16) //0 { } else if(ircode[2]==0x19) //- { } else if(ircode[2]==0x0d) //c { } else if(ircode[2]==0x0C) { } else if(ircode[2]==0x18) //2 27
displed(32); //1 单片机课程设计
} { } else if(ircode[2]==0x5E) //3 { } else if(ircode[2]==0x08) //4 { } else if(ircode[2]==0x1C) { } else if(ircode[2]==0x5A) { } else if(ircode[2]==0x42) //7 { } else if(ircode[2]==0x52) //8 { } else if(ircode[2]==0x4A) { } //9 //6 //5 void displed(uchar t) { while(1) { //一个 for(i=1;i<17;i++) for循环,分别选中16个列 { WriteS(0xff,0xff); yimaqi_154(i); //消影 //选 中列数据 WriteS(zifu[i*2-2+2*t],zifu[i*2-1+2*t]); //显示内容 //再//延 yimaqi_154(i); 选中列数据 delay1(7); 时的时间就是显示的时间
28
单片机课程设计
开列选 } } } EN=0; //打
3、元器件清单
序号 元器件名称 1 2 3 4 5 6 7 8 9 STC89C52RC单片机 74LS154译码器 USB插口 1N4007整流二极管 1K上拉电阻 1K电阻 10K电阻 8*8LED点阵 74HC595 数量 1 1 1 1 1 3 1 4 2 1 16 1 10 按键 11 510电阻 12 22uf电容
29
单片机课程设计
课程论文成绩评定表
指导老师评语: 成绩评定: 指导教师签名: 年 月 日
30