|
6B595或74HC595的C语言源程序 #include <reg51.h> #define uchar unsigned char uchar code DAT[18]={ 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x67,0xbf,0x86,0xdb,0xcf,0xe6,0xed,0x00,0x40 }; uchar DispDat[6]={ 1,2,3,4,5,6 }; sbit ENABLE=P3^3; sbit SERIALIN=P3^2; sbit CLOCK=P3^4; sbit LATCH=P3^5; void DispGroup(void) //6B595或74HC595显示123456 { uchar i,j,temp; for (i=0; i<6; i++) { temp=DAT[DispDat]; for (j=0;j<8;j++){ temp=temp<<1; SERIALIN=CY; CLOCK=1; CLOCK=0; } } LATCH=0; LATCH=1; } //在程序初始化时 CLOCK=0; LATCH=1; ENABLE=0;
|
|