LED16x32_595.c
上传用户:wxxy1999
上传日期:2008-02-13
资源大小:1k
文件大小:1k
- //2005-8-10
- //移位寄存器用74LS595
- #include <at89x51.h>
- #define SCK P0_0
- #define SCLR P0_1
- #define RCK P0_2
- #define OEN P0_3
- #define SER P0_4
- unsigned char code table_zhu[]={
- 0xF7,0xBF,0x77,0xBB,0xAC,0x0B,0xDF,0xB7,
- 0xAF,0xAF,0x68,0x01,0xF7,0xBF,0xE7,0x7F,
- 0xD6,0x03,0xB4,0xFB,0x72,0xFB,0xF6,0x03,
- 0xF6,0xFB,0xEE,0xFB,0xAE,0x03,0xDE,0xFB};/*"猪",0*/
- unsigned char code table_tou[]={
- 0xFF,0x7F,0xEF,0x7F,0xF3,0x7F,0xFB,0x7F,
- 0xEF,0x7F,0xF3,0x7F,0xF7,0x7F,0xFF,0x7F,
- 0x00,0x01,0xFF,0x7F,0xFE,0xBF,0xFD,0xDF,
- 0xFB,0xCF,0xF7,0xE7,0xEF,0xF3,0xDF,0xF7};/*"头",1*/
- void display(unsigned char);
- void delay1ms(void);
- void main (void)
- {
- unsigned char i;
- while (1)
- {
- for(i=0;i<16;i++)
- {
- P2=0x00+i;
- OEN=1;
- SCLR=0;
- SCLR=1;
- display(table_tou[2*i+1]);
- display(table_tou[2*i]);
- display(table_zhu[2*i+1]);
- display(table_zhu[2*i]);
- RCK=0;
- RCK=1;
- OEN=0;
- delay1ms();
- }
- }
- }
- void display(unsigned char dispcode)
- {
- unsigned char i;
- unsigned char temp;
- for (i=0;i<8;i++)
- {
- temp=dispcode&0x80;//一定要用变量代换;
- if (temp==0x80)
- {
- SER=1;
- }
- else
- {
- SER=0;
- }
- SCK=0;
- SCK=1;
- dispcode=dispcode<<1;//dispcode移位,不是temp移位;
- }
- }
- void delay1ms(void)
- {
- unsigned char j,k;
- // for(i=20;i>0;i--)
- for(j=2;j>0;j--)
- for(k=248;k>0;k--);
- }