这是驱动138的代码,就是上图运行的代码,看我的代码足以锻炼你的逻辑分析。
- #include "reg52.h"
- unsigned char code DuLiAnJian[]={1,2,4,8,16,32,64,128,254,253,251,247,239,223,191,127};
- bit k = 0;
- unsigned char code CHARCODE[32][8]={
- {0xFD,0xFD,0x0D,0xED,0xED,0xED,0x0D,0xFD},{0x0D,0xED,0xED,0xED,0x0D,0xFD,0xFD,0xFF},
- {0xFF,0xFF,0x00,0xFE,0xB9,0x7F,0x80,0xFF},{0x00,0xFE,0xB9,0x7F,0x80,0xFF,0xFF,0xFF},
- {0xEF,0xEF,0x0F,0xE0,0xEF,0x0F,0xFF,0x01},{0xDD,0xDD,0xDD,0xDD,0x01,0xFF,0xFF,0xFF},
- {0xBF,0xDD,0xEA,0xF7,0xE9,0x9E,0xBF,0x80},{0xBD,0xBD,0xBD,0xBD,0x80,0xBF,0xBF,0xFF},
- {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
- {0xFF,0xFF,0xA7,0xC7,0xFF,0xFF,0xFF,0xFF},{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
- {0x7F,0xBF,0xCF,0xE1,0xEF,0xEF,0xEF,0x00},{0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xFF,0xFF},
- {0xBF,0xBF,0xBD,0xBD,0xBD,0xBD,0xBD,0x80},{0xBD,0xBD,0xBD,0xBD,0xBD,0xBF,0xBF,0xFF},
- {0xFF,0xFF,0xFF,0x01,0x7D,0x7D,0x7D,0x7D},{0x7D,0x7D,0x7D,0x01,0xFF,0xFF,0xFF,0xFF},
- {0xFF,0xFF,0xFF,0x00,0xBF,0xBF,0xBF,0xBF},{0xBF,0xBF,0xBF,0x00,0xFF,0xFF,0xFF,0xFF},
- {0xFF,0x1F,0xFF,0x00,0xEF,0xDF,0xF7,0xF7},{0xF7,0x00,0xF7,0xF7,0x07,0xFF,0xFF,0xFF},
- {0xFE,0xFF,0xFF,0x00,0xFF,0x7E,0xBE,0xCE},{0xF2,0xFC,0xF2,0xCE,0xBE,0x7E,0x7E,0xFF},
- {0xFF,0xFF,0x1F,0x63,0x7B,0x7B,0x7B,0x0B},{0x7D,0x7D,0x7C,0x7D,0x7F,0x7F,0xFF,0xFF},
- {0xFF,0xDF,0xEF,0xF7,0xF9,0xBF,0x7F,0x80},{0xFF,0xFF,0xFD,0xFB,0xF7,0xCF,0xFF,0xFF},
- {0xFF,0x99,0x00,0x00,0x00,0x81,0xC3,0xE7},{0xFF,0x99,0x00,0x00,0x00,0x81,0xC3,0xE7},
- {0xFF,0x99,0x00,0x00,0x00,0x81,0xC3,0xE7},{0xFF,0x99,0x00,0x00,0x00,0x81,0xC3,0xE7}
- };
- void main()
- {
- unsigned char wei=0,Xd=0,Sw=0,By=8;
- unsigned int Ys=47474,Lx=0;
- P0=P1=P2=P3=0;
- while(1)
- {
- if(!--Ys)
- {
- P2=P3=255;
- if(k){P0=7;Sw=wei+2;P1=DuLiAnJian[Xd];}else{P1=0;Sw=wei;P0=By;if(++By>=16)By=8;}//后前DuLiAnJian[Xd]
- P3=CHARCODE[Sw+1][Xd];//下
- P2=CHARCODE[Sw][Xd];//上
- if(++Xd>=8){Xd=0;k=~k;++Lx;}
- if(Lx>74){wei+=4;Lx=0;}
- if(wei>=32)wei=0;
- Ys=247;
- }
- }
- }
复制代码 |