5 Autonomous Vehicles
5 Autonomous Vehicles
1 Date: D D - M M - Y Y
Theory: AVR Studio is an integrated development environment (IDE) for developing and debugging
AVR microcontroller applications. AVR Studio provides a complete set of features including project
file management, a C/C++ editor, navigation and code completion; a debugger supporting run
control including source and instruction-level stepping; registers, memory and I/O views; and target
configuration and management. AVR Studio supports all 8 and 32-bit AVR microcontrollers, and
connects seamlessly to debuggers and development kits.
Procedure:
• After installation, open AVR Studio 5 from Start → All Programs → Atmel AVR Tools → AVR
Studio 5.0
• After opening, you will see a Start Page like this. Click on “New Project…“.
1. In new projects page ensure that C/C++ is selected in Installed Templates and
AVRGCC C Executable Project is selected. Give a suitable project name (here name
given as Exp0). Click OK.
AVR Studio New Project
• Now, you will see the Device Selection dialog box. As you can see, AVR Studio supports all the
AVR MCUs. We choose ATmega32. Click OK.
• Now, you will see the following screen. Note that the basic program structure is already
prepared for you. You simply need to initialize your variables and place your code inside the
while(1) loop.
• Type in the following code and press save button as shown.
• Now select Build->Build Exp0 to build the project and generate Hex File. If build is
successful without any error, we get a Build successful message in Output window.
• Hex file with same name as project will be generated inside Debug folder in the location
where we saved the project during Step 2. This Hex file will be used for programming the
microcontroller.
Sample code
We will write the code for blinking an LED connected in pin A.0 with a delay in between.
int main(void)
{
DDRA = 0x01; // initialize port A.0 as o/p
while(1)
{
// LED on
PORTA = 0b00000001; // PA0 = High = Vcc
_delay_ms(500); // wait 500 milliseconds
//LED off
PORTC= 0b00000000; // PA0 = Low = 0v
_delay_ms(500); // wait 500 milliseconds
}
}
Result: