//****** Program function: drive 8-bit digital tube ****************************************
//****** MCU model: STC90C16RD+ ****************************************
//****** Date of writing: evening of June 8, 2013 ****************************************
//****** Written by: Elitah ***************************************
//############################################### ##################
//↓↓↓↓↓Predefined start############################################################
#include
#define uchar unsigned char
#define ulong unsigned long
//The following defines the disconnection interface
#define DuanXuan P0
//The following defines the bit selection interface
#define WeiXuan P2
//↑↑↑↑↑Predefined end##############################################################
//↓↓↓↓↓Start of global variables#########################################################
uchar HexCode [] = {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
uchar DispBit [] = {0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F};
//↑↑↑↑↑End of global variables##########################################################
//↓↓↓↓↓Function declaration begins##########################################################
void openDigitalTube(ulong);
void dispDigitalTube(int,int);
void delay(int) ;
//↑↑↑↑↑End of function declaration###########################################################
//↓↓↓↓↓Main function starts#############################################################
void main()
{
while(1)
{
openDigitalTube(99999999);
}
}
//↑↑↑↑↑End of main function#############################################################
[page]
//↓↓↓↓↓Function definition begins#########################################################
void openDigitalTube(ulong x)
{
if (x >= 0 && x < 10)
{
dispDigitalTube(x,7);
}
else if(x >= 10 && x < 100)
{
dispDigitalTube(x / 10,6);
dispDigitalTube(x % 10,7);
}
else if(x >= 100 && x < 1000)
{
dispDigitalTube(x / 100,5);
dispDigitalTube((x / 10) % 10,6) ;
dispDigitalTube((x % 100) % 10,7);
}
else if(x >= 1000 && x < 10000)
{
dispDigitalTube(x / 1000,4);
dispDigitalTube((x / 100) % 10,5);
dispDigitalTube((x / 10) % 10,6) ;
dispDigitalTube(x % 10,7);
}
else if(x >= 10000 && x < 100000)
{
dispDigitalTube(x / 10000,3);
dispDigitalTube((x / 1000) % 10,4);
dispDigitalTube((x / 100) % 10,5);
dispDigitalTube((x / 10) % 10,6) ;
dispDigitalTube(x % 10,7);
}
else if(x >= 100000 && x < 1000000)
{
dispDigitalTube(x / 100000,2);
dispDigitalTube((x / 10000) % 10,3);
dispDigitalTube((x / 1000) % 10,4);
dispDigitalTube((x / 100) % 10,5);
dispDigitalTube((x / 10) % 10,6) ;
dispDigitalTube(x % 10,7);
}
else if(x >= 1000000 && x < 10000000)
{
dispDigitalTube(x / 1000000,1);
dispDigitalTube((x / 100000) % 10,2) ;
dispDigitalTube((x / 10000) % 10,3);
dispDigitalTube((x / 1000) % 10,4);
dispDigitalTube((x / 100) % 10,5);
dispDigitalTube((x / 10) % 10,6) ;
dispDigitalTube(x % 10,7);
}
else if(x >= 10000000 && x < 100000000)
{
dispDigitalTube(x / 10000000,0);
dispDigitalTube((x / 1000000) % 10,1) ;
dispDigitalTube((x / 100000) % 10,2) ;
dispDigitalTube((x / 10000) % 10,3);
dispDigitalTube((x / 1000) % 10,4);
dispDigitalTube((x / 100) % 10,5);
dispDigitalTube((x / 10) % 10,6) ;
dispDigitalTube(x % 10,7);
}
}
void dispDigitalTube(int x,int y)
{
DuanXuan = HexCode[x];
WeiXuan = DispBit[y];
delay(10) ;
DuanXuan = 0xFF;
WeiXuan = 0xFF;
}
void delay(int x)
{
int i = 0,j = 0 ;
for(i = x;i > 0;i--)
for(j = 10;j > 0;j--) ;
}
//↑↑↑↑↑End of function definition#########################################################
Previous article:A fun C51 dynamic scanning applet
Next article:Play with LED dot matrix 1: 16X64 single red dot matrix static display
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Three steps to govern hybrid multicloud environments
- Three steps to govern hybrid multicloud environments
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- EEWORLD University ---- Haiwell IoT Cloud HMI Quick Start Video Tutorial
- MSP430FR6043 Ultrasonic Sensing Evaluation Module
- What are IoT programming tools?
- The pipes kept exploding, and finally the power supply was blown away.
- Verilog Golden Reference Guide Chinese Edition
- Analysis of the interface technology circuit of the sensor used in ESP
- 5G infrastructure opens new integration frontiers inside RF chips
- FM1702SL basic operation experience in developing IC card
- Multi-channel optical power meter based on MSP430F2272 MCU
- EEWORLD University ----PI new product: LinkSwitch-TNZ