Monday, November 4, 2024

More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages

Digital Clock with AM and PM Display

Seven-segment LEDs are widely used to display decimal numbers. Their major applications are in digital clocks, electronic meters and other numeral displays. Here we present the software program to replicate a digital clock with AM and PM display.

Screenshot of program output
Screenshot of program output

The program (digi_cloc.c) is written in ‘C’ language and uses the current time from a PC’s real-time clock. A 39.6cm (15.6-inch) LG Flatron W1643C monitor with 1366×768 resolution was used to test the program. The screenshot shows the output of this program.

Program functions
The program requires the egavga.bgi graphics file to be stored in the same folder as the executable file. When the program is run, the graphics system is initialised by loading a graphics driver from the system’s hard disk. The main functions used in the program for digital clock display are described below.

- Advertisement -

gdriver and gmode. These functions specify the graphics driver and graphics mode, respectively. The mode is set by the system automatically.

gettime( ). This function extracts the current time from the real-time system clock as structure time t. Here ‘t’ is the structure variable, which is used to access the hour element (ti_hour), minute element (ti_min) and second element (ti_sec). The structure is separated to digits and the corresponding seven-segment symbols displayed on the screen.

- Advertisement -

kbhit( ). This function returns a non-zero value when a key is pressed.

delay( ). It provides the required time delay in milliseconds.

closegraph( ). It switches the screen from graphics mode back to text mode.

Download source code: click here


The author is an assistant professor in electrical and electronics engineering at SACS M.A.V.M.M Engineering College, Madurai, Tamil Nadu

SHARE YOUR THOUGHTS & COMMENTS

EFY Prime

Unique DIY Projects

Electronics News

Truly Innovative Electronics

Latest DIY Videos

Electronics Components

Electronics Jobs

Calculators For Electronics