LED digital display electronic clock

Publisher:真诚友谊Latest update time:2016-10-20 Source: eefocusKeywords:LED Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

//***********************************
// LED digital display electronic clock
//***************************************

//***********************************

//Programming ideas:
//Use timer interrupt type digital tube dynamic scanning.
//Because the timekeeping part requires more precision, the timer automatic loading type is adopted, and timer 2 is used as the second generator, because timer 2 can be set to 16 bits for automatic loading,
#include
#include
#define uchar unsigned char
sure_time (void);
bit dis;
uchar code LED_DATA[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; //0~9 digital data
uchar data DATA_TEMP[8]; //Display buffer area, display 00-00-00 when booting
uchar data digit; //Shift variable (for dynamic scanning)
static uchar data t,k,i;
static uchar data sec=0,min=55,hour=22;
main ()
{    

 TMOD=0X01; //Timer 0
 ET0=1; //Open timer 0 interrupt
 EA=1; //Open general interrupt
 TH0=0XFC; //Timer 0 timing 1ms
 TL0=0X18;
 TR0=1; //Start timer
 RCAP2H=0X3C; //Timer 2 timing 50ms
 RCAP2L=0XB0;
 ET2=1;
 TR2=1;
 digit=0xfe;
 P3=0XFF; //Close display
 sure_time ();
 DATA_TEMP[2]=0XBF;
 DATA_TEMP[5]=0XBF;
 while (1)
  {
 

  }
}

void displayscanf (void) interrupt 1 //dynamic display scanning function
{   
 
  TH0=0XFC;
  TL0=0X18;
     P0=DATA_TEMP[i];
  i++;
  P3=digit;
  digit=_crol_(digit,1);
  if (i>7)
    {
      i=0;
   digit=0xfe;
    }
}

void timer_server (void) interrupt 5 //Clock timing
{

  TF2=0;
  t++;
  if (t==20)
   {
     t=0;
  sec++;
 
  if (sec>59)
    {
      sec=0;
   min++;
  
   if (min>59)
   {
   min=0;
   hour++;
  
     if (hour>23) hour=0;
     
   DATA_TEMP[1]=LED_DATA[hour%10];  
    DATA_TEMP[0]=LED_DATA[hour/10];
   }

  DATA_TEMP[4]=LED_DATA[min%10];
   DATA_TEMP[3]=LED_DATA[min/10];
    }

 DATA_TEMP[7]=LED_DATA[sec%10];
  DATA_TEMP[6]=LED_DATA[sec/10];
   }
   
}

sure_time (void) //Initialize the time and update the data in the DATA_TEMP array
{
 DATA_TEMP[1]=LED_DATA[hour%10];  
 DATA_TEMP[0]=LED_DATA[hour/10];
 DATA_TEMP[4]=LED_DATA[min%10];
    DATA_TEMP[3]=LED_DATA[min/10];
   DATA_TEMP[7]=LED_DATA[sec%10];
   DATA_TEMP[6]=LED_DATA[sec/10];
}

Keywords:LED Reference address:LED digital display electronic clock

Previous article:Digital tube scrolling display of numbers... (C program)
Next article:Design of frequency measurement system based on AT90S8515

Recommended ReadingLatest update time:2024-11-16 21:49

Detailed explanation of LED display knowledge
In recent years, with the holding of the Beijing Olympics, Shanghai World Expo, and Guangzhou Asian Games, LED display screens can be seen everywhere. LED display screens can display changing numbers, text, graphics and images; they can be used not only in indoor environments but also in outdoor e
[Power Management]
Key PWM control LED brightness single chip source program
The microcontroller source program is as follows: //Program name: Single-chip experiment instrument supporting program--pwm controls the brightness of LED //Circuit Introduction: 1. Connect P0 to the common positive end of the LED of J1; // 2. Connect P2.6 to J14 single-key keyboard 6 as a brightness increase button /
[Microcontroller]
Five key points to simplify LED driver design
Chip heating This is mainly for high-voltage driver chips with built-in power modulators. If the chip consumes 2mA of current and a voltage of 300V is applied to the chip, the power consumption of the chip is 0.6W, which will of course cause the chip to heat up. The maximum current of the driver chip comes
[Power Management]
ICLS602*X Series LED Bulb and LED Spotlight Driver IC
The ICLS60*X series ICs launched by Infineon contain four devices, namely ICLS6021J, ICLS6022J, ICLS6022G and ICLS6023J. This series of devices are suitable for building offline single-stage power factor correction (PFC) flyback switch power supply (SMPS) to drive LED bulbs and LED spotlights, which are used to replace
[Power Management]
ICLS602*X Series LED Bulb and LED Spotlight Driver IC
Chipone will increase the unit price of LED display driver products from April 1st, with an increase of 5% to 20%
Recently, Chipone announced a product contact letter. Chipone said that in order to ensure production capacity and supply, the tax-inclusive prices of all Chipone LED display driver products will be increased by 5%-20% based on the current prices. All price adjustment plans will be implemented on April 1, 2022. Regard
[Mobile phone portable]
Chipone will increase the unit price of LED display driver products from April 1st, with an increase of 5% to 20%
LED driver solution for low voltage backlight or flash applications
White LEDs are widely used in small liquid crystal display (LCD) panels and keyboard backlight and indicator applications. High-brightness LEDs are used as flash sources in mobile phones and digital cameras. These applications require optimized driver solutions that can extend battery life and reduce printed circuit bo
[Power Management]
LED driver solution for low voltage backlight or flash applications
Feasibility assessment and measurement results of LED street lights replacing traditional lighting
With the improvement of LED luminous efficiency and lifespan, coupled with the advantages of power saving, energy saving and environmental protection, the feasibility of LED replacing traditional lighting in street lighting has been greatly improved. With the rapid growth of LED technology and
[Power Management]
Development Trend of High Power LED Heat Dissipation Substrate
Due to the advancement of LED technology, LED applications are becoming more and more diversified, from early power indicators to LED lighting products with advantages such as power saving, long life and high visibility. However, since only 15 to 20% of the input power of high- power
[Power Management]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号