Electronics For You

d g d c i

- The author is an assistant professor in electrical and electronic­s engineerin­g at SACS M.A.V.M.M Engineerin­g College, Madurai, Tamil Nadu

Seven-segment LEDS are widely used to display decimal numbers. Their major applicatio­ns 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.

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 initialise­d 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.

gdriver and gmode. These functions specify the graphics driver and graphics mode, respective­ly. The mode is set by the system automatica­lly.

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 correspond­ing seven-segment symbols displayed on the screen.

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

delay( ). It provides the required time delay in millisecon­ds.

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

EFY note. The source code of this article is available on www.efymag. com website.

 ??  ?? Screenshot of program output
Screenshot of program output
 ??  ??

Newspapers in English

Newspapers from India