Static digital tube displays numbers and letters

First, let's take a look at the circuit structure of the digital tube. A digital tube is composed of seven lines and a decimal point. If you want to display numbers or letters, you can display them according to the shape. The digital tube in 51 single-chip microcomputer uses a common cathode connection, so for example, if you want to display the number 0, the a, b, c, d, e, and f of this digital tube are connected to high level, and g and dp are connected to low level, p0 The hexadecimal data corresponding to the port is 0x3f. Insert picture description here
Now we use the last nixie tube to display the numbers 0 to 9, then to the letters a to f. To display the last nixie tube but not the others, we need to control port A to C of the 138 decoder to low level. Insert picture description here
The reference code is given below.
#include “reg52.h”
typedef unsigned char u8;
typedef unsigned int u16;
typedef unsigned char u7;
sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;
u8 code smg[]={ 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71);
void delay(u16 i)
{ while( i-- ); } void main( ) {u7 a=0; LSA=0; LSB=0; LSC=0; while(1) {









for(a=0;a<16;a++)
{ P0=smg[a];
delay(50000);
}
}
}

We need to express the data we want to represent and the level of the letter corresponding to the P0 port first in hexadecimal, and then put them in an array in order, and finally only need a for loop to display what you want in turn Represents the numbers and letters. Of course, if you want to see the effect of sequential display, you also need a delay function, otherwise the naked eye cannot see the sequential display.

Guess you like

Origin blog.csdn.net/weixin_43789635/article/details/86748490