You are on page 1of 10

AVR

MICROCONTRO
LLER

ABOUT AVR
AVRwas developed in the year 1996 by
Atmel Corporation
Also known Advanced Virtual RISC
AVR microcontrollers are available in 3
categories
i.
Tiny AVR
ii. Mega AVR
iii. Xmega AVR

ATMEGA 32
FEATURES
8 bit microcontroller
It has 32K bytes of programmable flash
memory
2K bytes of SRAM
It is a 40 pin IC
32 programmable input/output lines
8 channel 10 bit ADC

PIN CONFIGURATION

PROJECT WORK
Designed 25V range DC voltmeter by
using ATmega32 microcontroller
COMPONENTS USED
i. power supply(5v),
ii. USBasp programmer
iii. 2*16 LCD
iv. 10k and 2k resistor

CIRCUIT DIAGRAM

CODE
#include<avr/io.h>
#include<util/delay.h>
#include<stdio.h>
#define F_CPU 1000000
#define enable
5
#define register selection 6
Void send_a_command(char command);
Void send_a_character(char character);
Void send_a_string(char string_of_character);
Void adc_init(void);
Int adc_value(void);
Int main()
{
DDRB=0xFF;
DDRD=0xFF;

adc_init();
float voltage=0;
int a;
char voltageshow[7];
send_a_command(0x01);
_delay_ms(50);
send_a_command(0x38);
_delay_ms(50);
send_a_command(0x80);
_delay_ms(50);
send_a_command(0x0E);
_delay_ms(50);
while(1)
{
a=adc_value();
voltage=((a*5)/1023)*5;
send_a_string(voltage=);
sprintf( voltageshow, %f ,voltage ) ;

send_a_string(voltageshow);
send_a_string(V);
}
}
Void send_a_command(char command)
{
PORTD &= ~ (1<<registerselection);
PORTD |= 1<<enable;
PORTB = command;
_delay_ms(2);
PORTD &= ~(1<<enable);
}
Void send_a_character(char character)
{
PORTD |= 1<<registerselection;
PORTD |= 1<<enable;
PORTB=character;
_delay_ms(2);
PORTD&=~(1<<enable);
}

void send_a_string(char*send_a_string)
{
while(*send_a_string != \0)
{
send_a_character(*send_a_string);
send_a_String++;
_delay_ms(50);
}
}

You might also like