Based on 51 single-chip microcomputer using eight digital tube patterns are shown below:
Xxx11xxx→xx2222xx→x333333x→44444444→x555555x→xx6666xx→x777777x→88888888
Each state is one second and the cycle repeats, where x indicates that the corresponding LED is off
Questions added: is the common anode digital tube, using 595 chip driver. Adopt C language.
================================================== =
The best answer: After the program is designed, use the PROTEUS simulation screenshot below.
The procedure is as follows:
//=============================================
#include
#define uint unsigned int
#define uchar unsigned char
//HC595 chip
Sbit H_ds = P2^0;
Sbit H_shcp = P2^1;
Sbit H_stcp = P2^2;
Char code DISP_8[] = {
0x00, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f};
Char code TAB_64[] = {
0,0,0,1,1,0,0,0, 0,0,2,2,2,2,0,0,
0,3,3,3,3,3,3,0, 4,4,4,4,4,4,4,4,
0,5,5,5,5,5,5,0, 0,0,6,6,6,6,0,0,
0, 7, 7, 7, 7, 7, 7, 0, 8, 8, 8, 8, 8, 8, 8, 8};
Char i = 1, j = 0;
Char DISP_B[] = {0,0,0,0,0,0,0,0};
//------------------------------------------------ ------------------
Void sendbyte_H(uchar aa) //Using HC595 output
{
Char z;
Aa = ~aa;
For(z = 0; z ? 8; z++) { // cycle 8 times into the data
H_shcp = 0;
H_ds = aa & 128; // data bits are sent to HC595 data line
H_shcp = 1; // rising edge input data
Aa "= 1;
}
}
//------------------------------------------------ ------------------
Void display()
{
Char z;
For(z = 0; z 8; z++) DISP_B[z] = TAB_64[j * 8 + z];
j++; j %= 8;
For(z = 0; z 8; z++) sendbyte_H(DISP_8[DISP_B[z]]);
H_stcp = 0; H_stcp = 1; // rising edge causes data to be output in parallel
}
//------------------------------------------------ ------------------
Void main()
{
TMOD = 0x01;
TH0 = (65536 - 46080) / 256; //2MHz
TL0 = (65536 - 46080) % 256;
TR0 = 1;
ET0 = 1;
EA = 1;
While (1);
}
//------------------------------------------------ ------------------
Void T0_TIme()interrupt 1
{
TL0 = (65536 - 46080) % 256; // reset the initial value
TH0 = (65536 - 46080) / 256; //2MHz
I--;
If (i == 0) {
i = 40;
Display(); // pattern display
}
}
//------------------------------------------------ ------------------
Sff-8644,High Speed Mobile Cable,Data Communication Cable,High Speed Communication Cable
Dongguan Aiqun Industrial Co.,Ltd , https://www.gdoikwan.com