YL-236設(shè)備上的,我的這個(gè)會(huì)有干擾
- #include<reg51.h>
- #include<intrins.h>
- #define uchar unsigned char
- #define uint unsigned int
- sbit cs1=P2^0; sbit cs2=P2^1; sbit wr=P2^2;
- void delay(uint i){while(--i);}
- void delays(uchar i)
- {
- uchar j;
- for(j=0;j<i;j++)
- {
- delay(55550);
- delay(55550);
- }
- }
- sbit row0=P3^7;sbit row1=P2^3;sbit col0=P2^4;
- sbit col1=P2^5;sbit col2=P2^6;sbit col3=P2^7;
- sbit ka1=P3^3; sbit ka2=P3^4; sbit ka3=P3^5; sbit ka4=P3^6;
- sbit LED1=P1^0; sbit pri=P1^1; sbit out1=P3^0; sbit out2=P1^2;
- sbit sw=P3^1; sbit sb=P3^2;
- //字模數(shù)組,一個(gè)8*8字符占1行
- uchar code zm[][8] =
- {
- 0x40,0x42,0x44,0xF4,0x40,0x40,0x47,0x44, //進(jìn)
- 0xF4,0x44,0x44,0x44,0x24,0x0A,0xF1,0x00,
- 0x04,0x04,0x14,0x3F,0x04,0x04,0x04,0x14,
- 0x3F,0x04,0x04,0x04,0x04,0x64,0x3F,0x00,
- 0x10,0x92,0x54,0x34,0x10,0xFF,0x10,0x18, //料
- 0x38,0xD4,0x54,0x12,0x11,0x10,0x10,0x10,
- 0x10,0x10,0x12,0x14,0x10,0x12,0x14,0x14,
- 0x70,0x1F,0x10,0x10,0x10,0x10,0x10,0x10,
- 0x48,0x88,0x88,0xE8,0x3F,0x28,0xC8,0x58, //攪
- 0x4C,0x4B,0x48,0x48,0x48,0x08,0x8A,0x64,
- 0x22,0x24,0x14,0x7F,0x40,0x20,0x1F,0x10,
- 0x12,0x12,0x12,0x12,0x12,0x45,0x44,0x78,
- 0x08,0x08,0x48,0x88,0x3F,0xC8,0x28,0x18, //拌
- 0x0C,0xEB,0x08,0x08,0x08,0x08,0x0A,0x04,
- 0x02,0x02,0x12,0x0A,0x02,0x3F,0x02,0x02,
- 0x22,0x7F,0x02,0x02,0x02,0x02,0x02,0x02,
- 0x08,0x08,0x08,0x48,0xFF,0x48,0x48,0x48, //加
- 0x48,0x44,0x44,0x44,0x44,0x52,0x21,0x00,
- 0x00,0x00,0x20,0x7E,0x22,0x22,0x22,0x22,
- 0x22,0x22,0x22,0x22,0x22,0x3E,0x22,0x00,
- 0x10,0x10,0x10,0xFE,0x10,0x50,0x38,0x16, //熱
- 0x10,0x10,0x94,0x48,0x00,0x12,0x22,0x21,
- 0x02,0x02,0x12,0x3F,0x12,0x12,0x13,0x12,
- 0x15,0x51,0x50,0x20,0x00,0x11,0x62,0x42,
- 0x10,0x12,0xD4,0x10,0x18,0x94,0x52,0x90, //裝
- 0xFF,0x40,0x20,0x30,0x28,0xA6,0x60,0x20,
- 0x02,0x12,0x3F,0x02,0x0A,0x1F,0x00,0x20,
- 0x7F,0x10,0x09,0x05,0x02,0x0C,0x70,0x20,
- 0x42,0xA4,0x14,0x7F,0x24,0x24,0x24,0x24, //瓶
- 0xFF,0x24,0x24,0xA4,0xA4,0xA2,0xA1,0x20,
- 0x20,0x7F,0x01,0x11,0x3F,0x11,0x11,0x13,
- 0x15,0x15,0x11,0x10,0x14,0x53,0x50,0x60
- };
- uchar buf[8]; //緩存
- uchar code ledcode[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};
- uchar buf1[8];
- void dis()
- {
- uchar i,j=0x7f;
- for(i=0;i<8;i++)
- {
- cs1=0;cs2=1;
- P0=ledcode[buf1[i]];wr=1;wr=0;
- cs1=1;cs2=0;
- P0=j;wr=1;wr=0;
- delay(100);
- cs1=cs2=1;
- j=_cror_(j,1);
- P0=0xff;wr=1;wr=0;
- }
- }
- void disp3216(){
- uchar i,n;
- uint row=0x01;
- for(i=0;i<16;i++){
- n=i<8?0:1;
- P0=zm[buf[0+4*n]][i-8*n]; col0=1;col0=0;
- P0=zm[buf[1+4*n]][i-8*n]; col1=1;col1=0;
- P0=zm[buf[2+4*n]][i-8*n]; col2=1;col2=0;
- P0=zm[buf[3+4*n]][i-8*n]; col3=1;col3=0;
- P0=row%0x100; row0=1;row0=0;
- P0=row/0x100; row1=1;row1=0;
- delay(50); row=_irol_(row,1);
- P0=0;
- row0=row1=col0=col1=col2=col3=1;
- row0=row1=col0=col1=col2=col3=0;
- }
- }
- void s16x16(uchar c,uchar n){
- c%=3;
- n=n*4+0; //計(jì)算字模實(shí)際行號(hào)
- buf[c]=n;buf[c+1]=n+2;
- buf[c+4]=n+1;buf[c+5]=n+3;
- }
- void init()
- {
- TMOD=0X01;
- EA=ET0=TR0=1;
- buf[0]=buf[1]=buf[2]=buf[3]=10;
- buf[4]=buf[5]=buf[6]=buf[7]=10;
- ka1=ka2=ka3=ka4=1;
- LED1=0;
- }
- bit workflag=1;
- void guti()
- {
- s16x16(0,0);
- s16x16(2,1);
- ka1=0;
- buf1[0]=1;
- delays(10);
- ka1=1;
- delays(5);
- ka1=0;
- buf1[0]=2;
- delays(10);
- ka1=1;
- }
- void main()
- {
- init();
- while(1)
- {
- if(sb==0){workflag=0;LED1=1;}
- while(workflag==0)
- {
- guti();
-
- }
- //dis();
- }
- }
- void time() interrupt 1
- {
- TH0=0XFC;
- TL0=0x17;
- disp3216();
- dis();
- }
復(fù)制代碼
|