AVR Board
AVR  arduino  atmel  board  code  core  data  design  development  device  features  flash  memory  USB  registers  microcontroller  power  program  programming  software 

AVR Tutorial

ATmega168A PWM - Pulse Width Modulation

Pulse-width modulation (PWM) is a commonly used technique for controlling power to inertial electrical devices, made practical by modern electronic power switches. The average value of voltage (and current) fed to the load is controlled by turning the switch between supply and load on and off at a fast pace. The longer the switch is on compared to the off periods, the higher the power supplied to the load is.


Take a look at  LED dimming example using PWM.

Analog to Digital Conversion Interrupts on an ATmega168A

In this tutorial we add a second analogue input and use the ADC Conversion Complete interrupt. The circuit we are using is similar to what we used last time but has an extra trimpot and uses an ATmega168A microcontroller. The ATmega168 is now obsolete, but its replacement (ATmega168A) is almost identical.

ad converter
This tutorial
shows you how to deal with A/D Conversion Interrupts.

A/D Conversion on an ATmega168

Many AVR microcontrollers are capable of doing Analogue to Digital Conversion. The ATmega168 has 6 ports (8 ports on the SMD packages) that can be used for analogue input.

AVR A/D converter

This tutorial
shows you how to deal with analog values.

Reading and writing Atmega168 EEPROM

EEPROM (Electrically Erasable Programmable Read Only Memory) Is non-volatile memory, meaning it persists after power is removed. The ATmega168 microcontroller has 512 bytes of EEPROM which can be used to store system parameters and small amounts of data.

AVR board with EEPROM

This tutorial shows you how to read and write EEPROM.

Introduction to I/O Registers

I/O pins are essential for any microcontroller. They allow communication with the world. I/O pins are usually grouped into I/O ports and registers.

The Atmega8 has 23 I/O ports which are organised into 3 groups:
  • Port B (PB0 to PB7)
  • Port C (PC0 to PC6)
  • Port D (PD0 to PD7)

These are shown on the pinout diagram below.

AVR Atmega8 IO Ports

This tutorial will teach you how to use the I/O ports on an AVR microcontroller. It uses an Atmega8 but the general principles apply to any AVR microcontroller.

External Interrupts on an ATmega168

What is an Interrupt?

Imagine your are sitting at your computer, reading this post. The phone rings and you answer it. After you hang up the phone (it was a telemarketer trying to sell you a timeshare), you get back to the awesomeness of the post, picking up where you left off.

Microcontroller interrupts are just like that.

  • The microcontroller is executing it’s main routine
  • An event occurs, which raises an interrupt
  • The Interrupt Service Routine (ISR) is run
  • On termination of the ISR, the microcontroller returns to it’s main routine, at the point where it left off
ATmega168 board

This tutorial will teach you how to use external and pin change interrupts on an AVR microcontroller. I will be using an ATmega168. The general principles apply to other AVR microcontrollers, but the specific vary greatly.