#include <> #include <> /*RCS2--->S1--->S2--->PC2 RCS1--->PC3'=1 */ #define RCS1_1 PORTC |=BIT(PORTC3) #define RCS2_1 PORTC |=BIT(PORTC0) #S1_1 PORTC |=BIT(PORTC1) #S2_1 PORTC |=BIT(PORTC2) #define RCS1_0 PORTC &=~BIT(PORTC3) #define RCS2_0 PORTC &=~BIT(PORTC0) #S1_0 PORTC &=~BIT(PORTC1) #S2_0 PORTC &=~BIT(PORTC2) #define DOTLEDPORT PORTA unsigned int RollCount=0; unsigned int SecondCount=0; unsigned char SecondFlag=0; const unsigned char DOTLEDBIT[]={ 0xfe, 0xfd,0xfb,0xf7, 0xef,0xdf,0xbf,0x7f, }; unsigned char ScanDOTLEDCount=0; unsigned char DOTLEDBuffer[32]; #pragma interrupt_handler timer1_ovf_isr:7 void timer1_ovf_isr(void) {TCNT1H =0xFE; TCNT1L =0x0C; //点阵 LED 扫描过程 if(ScanDOTLEDCount<8) {DOTLEDPORT=DOTLEDBIT[ScanDOTLEDCount%8]; CCS1_1; CCS1_0; DOTLEDPORT=0xff; CCS2_1; CCS2_0; }else {DOTLEDPORT=0xff; CCS1_1; CCS1_0; DOTLEDPORT=DOTLEDBIT[ScanDOTLEDCount%8]; CCS2_1; CCS2_0; }DOTLEDPORT=DOTLEDBuffer[ScanDOTLEDCount*2+1]; //下半屏的数据 RCS2_1; RCS2_0; DOTLEDPORT=DOTLEDBuffer[ScanDOTLEDCount*2]; //上半屏的数据 RCS1_1; RCS1_0; ScanDOTLEDCount++; if(ScanDOTLEDCount==16)ScanDOTLEDCount=0; //******************************************** SecondCount++; if(SecondCount==100) {SecondCount=0; SecondFlag=1; }}void main(void) {unsigned int i; CLI(); PORTA =0xFF; DDRA =0xFF; PORTC =0x00; DDRC =0x0F; TCCR1B =0x00; TCNT1H =0xFE; TCNT1L =0x0C; TCCR1A =0x00; TCCR1B =0x02; MCUCR =0x00; EM
16x16点阵LED滚动显示汉字 来自淘豆网m.daumloan.com转载请标明出处.