《实验二数码管显示序号.docx》由会员分享,可在线阅读,更多相关《实验二数码管显示序号.docx(8页珍藏版)》请在第一文库网上搜索。
1、实验一学号滚动显示#includeint count,j,i;code char tab=0x5b,0x3f,0x6d,0x4f,0x5b,0x3f,0x3f,0x66,0x06,0x6f;学号code char TABl=0XFE,0XFD,0XFB,0XF7z0XEF,0XDF,0XBFz0X7Fhvoid delay(int ms)(int ij;for(i=0;ims;i+)for(j=0;j110;j+);)void main()(TMOD=0X10;EA=1;ET1=1;TR1=1;THl=(65536-1000)/256;TLl=(65536-1000)%256;while(l)
2、(for(i=0;ij;i+)(if(i=7)(P0=tabj-i-l;P2=TABli;delay ;)void time_l() interrupt 3(THl=(65536-1000)/256;TLl=(65536-1000)%256;count+;if(count=1000)(count=0;j+;)if(j=H)(j=l;)实验二数码管显示序号#includecode char tab=03f,0x06,05b,0x4f,066,06dz0x7d,0x07,0x7f,0x6f;sbit P1O=P1AO;void main()(TMOD=0X10;EA=1;ET1=1;THl=(65
3、536-1000)/256;TLl=(65536-1000)%256;while(l)(P10=0;if(P3=0X7F)P0=tabl;P2=0XFE;TRl=0;else if(P3=0XBF)P0=tab2;P2=0XFD;TRl=l;else if(P3=0XDF)P0=tab3;P2=0XFB;TRl=0;else if(P3=0XEF)P0=tab4;P2=0XF7;TRl=l;else if(P3=0XF7)P0=tab5;P2=0XEF;TRl=0;else if(P3=0XFB)P0=tab6;P2=0XDF;TRl=l;else if(P3=0XFD)P0=tab7;P2=
4、0XBF;TRl=0;else if(P3=0XFE)P0=tab8;P2=0X7F;TRl=l;)void time_0() interrupt 3(THl=(65536-1000)/256;TLl=(65536-1000)%256;P1O=P1O;)实验三串口接收#includesbit DEEP=P20junsigned char Tab=0x3F,0X06,05B,0x4Fz0x66,0x6d,0x7d,0x07,0x7f,0x6fjvoid main(void)(char i;SCON=0X50;TMOD=OX21;TH0=(65536-1000)/256;TL0=(65536-10
5、00)%256;TH1=OXE6;TL1=OXE6;TR1=1;while(l)(while(RI)(i=SBUF;Pl=Tabi;RI=0;if(i%2=0)(EA=1;ETO=1;TRO=1;)else(EA=O;ETO=O;TRO=O;)void time0(void) interrupt 1TH0=(65536-1000)/256;TL0=(65536-1000)%256;DEEPDEEP;TRO=1;)波特率1200;实验四光敏#includesbit P10=P10jvoid main(vod)(TMOD=0x01;TH0=(65536-100)/256;TL0=(65536-100)%256;EA=1;ETO=1;while(l)(if(P2=0FE)(TR0=0;P10=l;)elsed-=0d9S3%(00T-9E9S9)=011S3(00T-99S9)=0Hl)工)drw3)i!(p!A)0J3u!j p0O=Old