Digital Stop Watch with ATmega8 using microcontroller

Nov 13, 2012 by


Hello Friends,

In this tutorial we will make a “Digital Stop Watch” using an AVR ATmega8 Microcontroller. This will help you learn many concepts like

  1. Multiplexed Seven Segment Display Interfacing
  2. Using AVR Timers
  3. Using Interrupts
  4. And many others too.

The code is written in C language for avr-gcc (WinAVR) .

Digital Stop Watch

Steps to Build the “Digital Stop Watch” using AVR ATmega8 MCU

  1. Make the circuit according to the schematic on general purpose PCB or a BreadBoard.
  2. Make a project in AVR Studio and add a new file to the project. Copy/paste the “c” code. Set optimization as “o2” and CPU frequency as 16000000Hz. Save and Build the project. You will get a HEX file.
  3. Burn this HEX file to an ATmega8 MCU using a tool such as eXtreme Burner AVR.
  4. Set High Fuse = C9(Hex) Low Fuse = FF(Hex). How to do this depends on you programmer software.

I have use a xBoard MINI development board for fast and easy prototyping. The Displays+Transistors+Key are on the Veroboard while the Core CPU unit + power supply is in the xBoard MINI. It can be programmed “In System” over USB Port using eXtreme Burner – AVR software toolkit.

How to Use the “Digital Stop Watch”

When initially powered up the Stop watch is in “STOP” condition. This is indicated by a blinking display. The count is 00:00 initially. Press “START” to start the watch. The blinking will now stop and the display will be fully on. It will start counting and MIN:SEC is displayed. The stop watch can be halted at any time by pressing “HALT” key. In halt state the counting freezes and the display starts blinking. You can press “START’ key again to resume counting from there. The “RESET” key is used to reset the clock to 00:00 i.e. 0 minute and 0 sec.

Digital Stop Watch Schematic

Digital Stop Watch Schematic

Digital Stop Watch C Source Code.

 /*
  Description:
 An AVR ATmega8 based Digital Stop Watch
   Project.
  ________________________________________________________
   */ 
#include <avr/io.h>  
#include <avr/interrupt.h>  
#include <util/delay_basic.h>  
#define true 1 #define false 0  
#define SEVEN_SEGMENT_PORT PORTD  
#define SEVEN_SEGMENT_DDR DDRD   
volatile uint8_t digits[4];   
//Global variable for the clock system   
volatile unsigned int clock_millisecond=0;   
volatile unsigned char clock_second=0;   
volatile unsigned char clock_minute=0;   
volatile unsigned char clock_hour=0;   
//Display hiding system   
uint8_t hide_display = false;   
//Blinking system   
uint8_t blink_display = true; 

For more detail: Digital Stop Watch with ATmega8 using microcontroller 

Leave a Comment

You must be logged in to post a comment.

Recent Posts

I2C Bus for ATtiny and ATmega

I2C Bus for ATtiny and ATmega

I love the Atmel AVR microcontrollers! Since building the Ghetto Development System described in thi[...]
Interfacing GY 26 with atmega640

Interfacing GY 26 with atmega640

Hello friend once again with new instructable in this I will show you how to interface GY 26 with UA[...]
Using Atmega32 with Arduino IDE

Using Atmega32 with Arduino IDE

Over time I have used all kinds of Atmel microcontrollers in various projects. One of the mos[...]
Standalone Arduino / ATMega chip on breadboard

Standalone Arduino / ATMega chip on breadboard

Step 1: Parts needed I bought my parts from Digikey and Sparkfun Electronics - they're 2 of my favo[...]
Burning atmega328-pu and atmega328p-pu bootloader

Burning atmega328-pu and atmega328p-pu bootloader

Burning the boot loader in an atmega328 could be somewhat tricky but if u follow these steps correct[...]

Read more:
CO2 meter and Xively logger with NDIR infrared sensor built on AVR ATmega328
Close