You Are Here: Home » AVR ATmega Projects » Relay Timer with ATmega8 AVR MCU

Relay Timer with ATmega8 AVR MCU




Timers are widely used in industrial and domestic application for automating tasks. Microcontrollers can be used to design versatile and accurate timers with ease. Here I present a simple timer that can be used to turn on/off a load after user specified time.

The Timer uses a standard 16×2 lcd module for user interface (UI). User can set the time using a 3 button keypad.

After that Timer is started. While count down is in progress, the time left is displayed on screen.

The program use our LCD driver library more details of which can be found in here. Use avr-gcc + AVR Studio to compile.

The prototype was developed using xBoard MINI, a low cost easy to use ATmega8 development board. The program was burned to the MCU’s flash memory using eXtreme Burner – AVR Software and Hardware. A basic knowledge of working with different tools of AVR development is required, so please refer to following articles.

Note:

  • Fuse Must be set as follows, HIGH FUSE=C9 LOW FUSE=FF (Very Important)
  • If display is blank please adjust RV1
Part List
01ATmega8-16 PUU1
0216×2 LCD ModuleLCD1
0316 MHz CrystalX1
04BC548 TransistorQ1
051N4007 DiodeD1
064.7K ResistorR1,R2
0710K Variable ResistorVR1
0822pF Disk Capacitorc1,c2
090.1uF Disk Capacitorc3,c4
10Large Push Buttonss1,s2,s3
11PCB Mountable RelayRL1

Schematic (Circuit Diagram)

Relay Timer Thumb

Program

 /******************************************************
   A Simple Device Timer project designed using ATmega8
   AVR MVU. The Timer is usefully for keeping a device
   "ON" for a specific period of time. After the set
   time elapse the timer automatically turns the load off.
   The Timer uses a standard 16x2 lcd module for user interface
   UI. User can set the time using a 3 button keypad.
   After that Timer is started. While count down is in
   progress, the time left is displayed on screen.
   The program use our LCD driver library more details
   of which can be found in Web site.
   Use avr-gcc + AVR Studio to compile.
  ******************************************************/ 
#include <avr/io.h>  
#include <avr/interrupt.h>  
#include "lcd.h"
//Connection of Load 
#define LOAD_DDR DDRC  
#define LOAD_PORT PORTC  
#define LOAD_POS PC0  
//Global variable for the clock system  
volatile unsigned int clock_millisecond=0;  
volatile char clock_second=0;  
volatile char clock_minute=0;  
volatile char clock_hour=0;
For more detail: Relay Timer with ATmega8 AVR MCU

Leave a Comment

You must be logged in to post a comment.

Read previous post:
The Atmel AVR Microcontroller: MEGA and XMEGA in Assembly and C – AVR E-Book

Offering comprehensive, cutting-edge coverage, THE ATMEL AVR MICROCONTROLLER: MEGA AND XMEGA IN ASSEMBLY AND C delivers a systematic introduction to...

Close
Scroll to top