Name: 8 Digit Rolling Display of Number String
Software: Proteus
Keil 4
Language: C Language
Usage Instructions: In this example, the simulation of 8 digit displays rolling to the left shows a number string consisting of 3 characters.
Example Image:
Proteus Simulation – 8 Digit Rolling Display of Number String
Program:
-
/*
-
Name: 8 Digit Rolling Display of Number String
-
Description: The digit display rolls to the left showing a number string made of 3 characters
-
*/
-
#include
-
#include
-
#define uchar unsigned char
-
#define uint unsigned int
-
// Segment Code Table
-
uchar code DSY_CODE[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};
-
// The following array is considered as a circular queue, displaying 8 numbers starting from a certain number (10 indicates black screen)
-
uchar Num[]={10,10,10,10,10,10,10,10,2,9,8};
-
// Delay
-
void DelayMS(uint x)
-
{
-
uchar t;
-
while(x–) for(t=0;t<120;t++);
-
}
-
// Main Program
-
void main()
-
{
-
uchar i,j,k=0,m=0x80;
-
while(1)
-
{ // Refresh several times to maintain a stable display for a period
-
for(i=0;i<15;i++)
-
{
-
for(j=0;j<8;j++)
-
{
-
// Send segment code, using circular access starting from the k-th
-
P0=0xff;
-
P0=DSY_CODE[Num[(k+j)%11]];
-
m=_crol_(m,1);
-
P2=m; // Send digit code
-
DelayMS(2);
-
}
-
}
-
k=(k+1)%11; // Increment k for circular queue head, Num index range 0~10, hence modulo 11
-
}
-
}
/***************Elegant Divider***********************/
Program:
The Proteus software is an EDA tool developed by Labcenter Electronics in the UK, representing a new generation of electronic design platforms that integrate teaching, experimentation, and design; it includes functions for electrical and electronic simulation design, electronic technology simulation design, and microcontroller application design verification. It runs on Windows operating systems and can simulate and analyze various analog devices and integrated circuits (SPICE).
The Proteus Tutorial Resource Network (proteuseda.com) was founded in 2018, and the site owner, as an electronic engineer, is dedicated to promoting the development of electronic design automation in China, collecting and sharing various excellent Proteus simulation tutorials and materials. I hope to contribute a little to China’s intelligent manufacturing.
/*******************************************/
Click the bottom right “Read the Original” for more simulation examples