Beginner's Guide - AVR Programming

by cl97 in Workshop > Science

48703 Views, 67 Favorites, 0 Comments

Beginner's Guide - AVR Programming

DSC_0020.JPG
You will get this done in 30 min.

Parts

1. 1 X  any type of circuit board
2. 1 X Atmel AVR Atmega16 microcontroller
3. 8 X 330 ohms Resistors
4. 8 X LEDs
5. 1 X AVR Programmer (just use for download the code, i used a STK500)

Build the Circuit

Picture1.jpg
DSC_0001.JPG
It's very simple, just follow the diagram that i attached.

Download the Code

01.JPG
02.JPG
03.JPG
04.JPG
05.JPG
Now you can download the code. I am using the AVR Studio to download the code. You may copy and past this code to AVR studio:

#include

int main(void)
{
    DDRD = 0xff;
    while(1)
    {
        PORTD = 0b11100110;
    }
}

or you can download the teset1.hex that i already build.

Downloads

Result

DSC_0020.JPG
You will see the result from the LEDs.
8 LEDs represent 8 bits: 11100110 (light up=1, off=0)

Make the LEDs Flashing

It will be a  easy. You will only need to write a loop for it. The only thing you need to concern is the frequency, because our eyes may not see the light flashing in micro seconds.

This is my first write up, if any thing is not right please let me know.
Thank you very much.