Real Time Clock (RTC) is used for tracking time and maintaining a calendar.
Many applications require that a record is kept of the time when certain events occur. RTCs are useful in such applications.
code and circuit diagram
visit for ATmega16/32: http://electronicwings.com/avr-atmega...