Tech Tutorials > AVR Code Examples


Here are some of the programs demonstrating the features of the AVR microcontrollers. The ordering is mostly according to increasing difficulty.

It would be better if you keep the AVR Datasheet open and have a look at the various registers used in the programs. The "Register Summary" on page 334 of this datasheet would be helpful to find the Register's detailed page.

If you have any doubts, feel free to contact me.

Using Ports

  1. Toggle a pin - View Online | Download C file
  2. Bidirectional Single motor drive - View Online | Download C file
  3. Two Motor bidirectional drive (one motor running at a time) - View Online | Download C file
  4. Controlled toggling of a pin - View Online | Download C file
  5. PWM (ON time follows a sawtooth wave, slow rise and sudden fall) - View Online | Download C file
  6. PWM (ON time follows a triangular wave, slow rise and slow fall) - View Online | Download C file

ADC

  1. ADC as a comparator - View Online | Download C file
  2. Selecting the ADC input pin (through ADMUX) - View Online | Download C file

Timers

  1. Flashing a LED - View Online | Download C file
  2. PWM generation using timers - View Online | Download C file

Interrupts

  1. ADC interrupt - View Online | Download C file
  2. Timer interrupt - View Online | Download C file

Tech Tutorials > AVR Code Examples