beautypg.com

Pololu USB AVR User Manual

Page 14

background image

2. In the Device Selection window, select the device name of your specific AVR. Click OK to create the project.

The Device Selection dialog of Atmel Studio 6.

3. Remove the template code that was automatically placed in BlinkLED.c and replace it with the code below:

#define F_CPU 20000000 // AVR clock frequency in Hz, used by util/delay.h

#include

#include

int main() {

DDRD |= (1<

while (1) {

PORTD |= (1<

_delay_ms(100); // delay 100 ms

PORTD &= ~(1<

_delay_ms(900); // delay 900 ms

}

}

Note: The value of F_CPU should be the clock frequency of your AVR in units of Hz, so if your AVR
is not running at 20 MHz you will need to change that line. If you do not make this change, the timing
of

_delay_ms()

will be off, but the LED will still blink.

4. Click the Build Solution button on the toolbar (or press F7) to compile the code.

Pololu USB AVR Programmer User's Guide

© 2001–2014 Pololu Corporation

3. Getting Started in Windows

Page 14 of 54