LED点阵

时间:2025-03-07 09:49:11
#include <> #include <> sbit RCK=P3^5; sbit SCK=P3^6; sbit SER=P3^4; unsigned char code Animation[]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0x08,0x08,0x08,0xff,0x00,0x0e,0x15, 0x15,0x15,0x08,0x00,0x7e,0x01,0x02,0x00, 0x7e,0x01,0x02,0x00,0x0e,0x11,0x11,0x0e, 0x00,0x7d,0x00,0x00,0x00,0x00,0x00,0x00,}; void Delay (unsigned char xms) { unsigned char i, j; while(xms>0) { _nop_(); i = 2; j = 199; do { while (--j); } while (--i); xms--; } } void Write(unsigned char Byte) { unsigned char i; for(i=0;i<8;i++) { SER=Byte&(0x80>>1); SCK=1; SCK=0; } RCK=1; RCK=0; } void ShowColumn(unsigned char Column,Data) { Write(Data); P0=~(0x80>>Column); Delay(1); P0=0xff; } void main() { unsigned char i, j; SCK=0; RCK=0; while(1) { for(i=0;i<8;i++)ShowColumn(i,Animation[i+j]); j++; if(j>38)j=0; } }