Sunteți pe pagina 1din 13

184914765

win avr
a studio 589 /bug
win 32 executable
glow of a single led
glow alll the connected on your board
blink a single led
blink all the connected on ur board
glow and blink the led position at even place
glow and blink the led position at odd place
blink the led s position at even and odd place
glow and blink the

================================================================================
=======================

shft a sngle led twrds right


shft a sngle led twrds right
right left shiftng of led
converging led
diverging led
converging-diverging led
sand watch led twrds right and left
sand watch frm right and left . the led shld

disply single frm 0to 9 at delay of 1 second


display any two digit no.
display any three digit no .
wap to display the no. frmm 0-100 on led on your board and simultaneously displ
y on seven segment display .
wap to prgrm to generate at least 5 diff. pattern on the led on ur kit . the pat
tern must be appear aftr a grp of 1 second and should hve a period of 2 second
.
================================================================================
=======================
glow a led in 3 rd n 4 th coloum
shift a complete coloum towards right
shift a row

int main()

{
configure the LCD
LCD_cmd(0x40);
LCD_write(0x00);
0
4
e
e
e
1f
04
00
LCD_cmd
80
LCD_write(0);

return 0;
}

0x40 = first addressing


================================================================================
=======================
1. wap tp print all the alphebet of eng. dict. with a dislplay of 1 second in
the 2nd row and 5th coloum ?
2. wap to program scroll a msg frm left to right in frst row ?
3. wap to to display a 2 digit no on the LCD?
4. wap to display any no. ?
1.
2.
ck
3.

wap to display ur name in sand watch format ?


design a digital clock such that the frst row of the LCD display digitaal clo
and the second row
display the clock in the format HH:MM:SS ?
modify the clock as ur creation ?

#include<avr/io.h>
#include<util/delay.h>
#define
#define
#define
#define

LCD_cntrl PORTD
rs PD0
rw PD1
en PD2

void LCD_cmd(unsigned char cmd){


LCD_cntrl=cmd;
LCD_cntrl |=(0<<rs)|(0<<rw)|(1<<en);
_delay_ms(1);
LCD_cntrl |=(0<<rs)|(0<<rw)|(0<<en);
}
void LCD_data(unsigned char data){
LCD_cntrl=data;
LCD_cntrl |=(1<<rs)|(0<<rw)|(1<<en);
_delay_ms(1);
LCD_cntrl |=(1<<rs)|(0<<rw)|(0<<en);
}
void Fourbit_cmd (unsigned char cmd){
unsigned char var;
var=(cmd & 0xF0);
LCD_cmd(var);
var=((cmd<<4) & 0xF0);
LCD_cmd(var);
}
void Fourbit_data (unsigned char data){
unsigned char var;
var=(data & 0xF0);
LCD_data(var);
var=((data<<4) & 0xF0);
int main(){
DDRD=0xFF;
LCD_int();
while(1){
Fourbit_cmd(0x80);
Fourbit_data(65);
}
return 0;
}

void LCD_string(unsigned char *str)


{
unsigned int i=0;
while(str[i]='\0')
{
fourbit_data(str[i]);
i++ ;
}
}

void LCD_number(unsigned int num)

{
fourbit _cmd(0x04);
unsigned int x ;
while(num!=0)
{
x=num%10;
fourbit_data(x+48);
num=num/10;
}
fourbit_cmd(0x06);
}
fourbit_cmd(0x82);
LCD_number(576);

================================================================================
=======================
4 pin of porb b is attach
to motor .

1. wap to move the robo in ol the directions for 2 second in each directions .
2. modify the above prgrm to simultaneously display the direction of motion of t
he motors on the LCD.
3. modify the abov prgrm to display the values being given to the input pins of
the IC L293d on the LEDs .

while(1)
{ if (PINA & 00000001)
{PORTB=00000

unsigned int x;
while(1)
{
x=read_ADC(0);
if(x<=200)
{
PORTB=ob00000001 ;
}
if((x<=400)&(x>200)

{ PORTB=0b00000010;

}
.
.
.
so on

#include<avr/io.h>
#include<util/delay.h>
#define ADC_VREF_TYPE 0X40
#define
#define
#define
#define

LCD_cntrl PORTD
rs PD0
rw PD1
en PD2

void LCD_cmd(unsigned char cmd){


LCD_cntrl=cmd;
LCD_cntrl |=(0<<rs)|(0<<rw)|(1<<en);
_delay_ms(1);
LCD_cntrl |=(0<<rs)|(0<<rw)|(0<<en);
}
void LCD_data(unsigned char data){
LCD_cntrl=data;
LCD_cntrl |=(1<<rs)|(0<<rw)|(1<<en);
_delay_ms(1);
LCD_cntrl |=(1<<rs)|(0<<rw)|(0<<en);
}
void Fourbit_cmd (unsigned char cmd){
unsigned char var;
var=(cmd & 0xF0);
LCD_cmd(var);
var=((cmd<<4) & 0xF0);
LCD_cmd(var);
}
void Fourbit_data (unsigned char data){
unsigned char var;
var=(data & 0xF0);
LCD_data(var);

var=((data<<4) & 0xF0);


LCD_data(var);
}
void LCD_int(void){
Fourbit_cmd(0x02);
Fourbit_cmd(0x28);
Fourbit_cmd(0x0C);
Fourbit_cmd(0x85);
Fourbit_cmd(0x06);
}
void ADC_int(void)
{
ADMUX=(ADC_VREF_TYPE & 0X7f);
ADCSRA=0X87;
}
unsigned int read_adc(unsigned char adc_input)
{
ADMUX=(adc_input)|(ADC_VREF_TYPE & 0X7f) ;
_delay_ms(10);
ADCSRA|=0X40;
while(!(ADCSRA & 0X10));
ADCSRA|=0X10;
return ADC ;
}

void LCD_number(unsigned int num)


{
Fourbit_cmd(0x04);
unsigned int x ;
while(num!=0)
{
x=num%10;
Fourbit_data(x+48);
num=num/10;
}
Fourbit_cmd(0x06);
}

int main()
{
unsigned int i,j;
DDRD=0Xff;
LCD_int();
ADC_int();
while(1)
{
i=read_adc(0);
j=read_adc(1);

Fourbit_cmd(0x84);
LCD_number(i);
Fourbit_cmd(0x8A);
LCD_number(j);
}
}

LFR ROBOT
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------1-1 = F
1-0 = R
0-1 = L
0-0 = STOP/ BACKWRD

int main()
{
DDRA=0X00;
DDRB=0Xff;
while()
{
x=PINA & 0b00000011 ;
if(x==3)

int main()
{
DDRA=0x00;
DDRB=0XFF;
ADC_init();
while()
{
i=read_adc(0);
j=read_adc(1);
else if((i>300)&&(j>300));
{
PORTB=ob00001001;
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------LFR CODE

#include<avr/io.h>
#include<avr/io.h>
#include<util/delay.h>
int main()
{
DDRA=0X00;
DDRB=0Xff;
unsigned int x;
while(1)
{
x=PINA & 0b00000011; //f
if(x==3)
{
PORTB=0X09; //F
}
else if(x==2)
{
PORTB=0b00001010;

//l

}
else if(x==0x01)
{
PORTB=0b00000101; //r
}
else
{
PORTB=0X00;

//s

}
}
return(0);
}
-----------------------------------------------------------------------------------------------------KEYPAD
-----------------------------------------------------------------------------------------------------DDRD=0Xff
DDRD=0Xff
PORTA=0X0f
while(1)
{
if(PINA & 0b00000001)==0 {PORT B = obooooooo1;
if((PINA
if((PINA
if((PINA
if((PINA

&
&
&
&

ob00001111)==0x0E)
Ob00001111)==0x0D)
ob00001111)==0x0B)
ob00001111)==0x07)

{PORTB=0X01;}
{PORTB=0X02;}
{PORTB=0X04;}
{PORTB=0X08;}

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

keypad code
#include<avr/io.h>
#include<util/delay.h>
int main()
{
DDRB=0xff;
DDRD=0Xff;
DDRA=0X00;
PORTA=0X0f;
while(1)
{
PORTD=0b00001110;
_delay_ms(50);
if((PINA &0b00001111)==0x0e)
{PORTB=0X01;}
if((PINA &0b00001111)==0x0d)
{PORTB=0X02;}
if((PINA & 0b00001111)==0x0b)
{PORTB=0X03;}
if((PINA & 0b00001111)==0x07)
{PORTB=0X04;}
}
PORTD=0b00001110;
if((PINA &0b00001111)==0x0e)
{PORTB=0X05;}
if((PINA &0b00001111)==0x0d)
{PORTB=0X06;}
if((PINA & 0b00001111)==0x0b)
{PORTB=0X07;}
if((PINA & 0b00001111)==0x07)
{PORTB=0X08;}
}
PORTD=0b00001110;
if((PINA &0b00001111)==0x0e)
{PORTB=0X09;}
if((PINA &0b00001111)==0x0d)
{PORTB=0X0a;}
if((PINA & 0b00001111)==0x0b)
{PORTB=0X00b;}
if((PINA & 0b00001111)==0x07)

{PORTB=0X0c;}
}
PORTD=0b00001110;
if((PINA &0b00001111)==0x0e)
{PORTB=0X0d;}
if((PINA &0b00001111)==0x0d)
{PORTB=0X0e;}
if((PINA & 0b00001111)==0x0b)
{PORTB=0X0f;}
if((PINA & 0b00001111)==0x07)
{PORTB=0X1f;}
}
return (0);
}

1.wap to display the binary code of the key .

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------LCD-KEYPAD
int num_input()
{
int x,y=0;
while (x=keypad()!=4)
{
y=108y+x ;
_delay_ms(2000);
}
return y ;
}
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------EXERCISE
1. DESIGN A PREPROGROMMED PASSWD CONTROL LED LIGHTING SYSTEM ? (IN THIS THE USE
R WILL ENTER THE PASSWORD TO OPEN THE SYSTEM AND IS ABLE TO DISLPAY DIFF. LIGHTI
NG PATTERN ON LED USING DIFF. KEYS OF THE KEYPAD ).
2. DESIGN A PREPROGRAMMED CONTROLL KEYPAD ROBOT ?

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------1.vol. at pin in mv= reading from adc *5000/1024 ?

1. wap to show the value of the temp. sensor on LCD .?


2. design a digital thermometer ?
3. wap to control the LED pattern using temp. sensor and at the same time displa
y the temperature ?
4. design a temerature controlled fan ?

================================================================================
======================
1.
2.
3.
4.

wap
wap
wap
wap

to
to
to
to

generating a beep through a buzzer ?


generate the beep in patterns?
interface the buzzer with the keypad ?
high temperature alarm system ?

================================================================================
=======================
creating header file ?
1.include "lcd.h"o .
1. wap to glow a LED frm minimum brightness to max bightness and vice versa ?

#include<avr/io.h>
#include<util/delay.h>
void init PWM()
{
TCCR0|=(1<<WGM00)|(1<<WGM01)|(1<<COM01)|(1<<CS00);
DDRB|=(1<<PB3);
}
void main ()
{
unsigned int brightness=0;
init PWM();
while(1)
{
OCR0=10;
_delay_ms(5);
}
}

================================================================================
=======================

DIGITAL PIANO
================================================================================
=======================
INTERRUPTS
---------#include<avr/io.h>
#include<util/delay.h>
#include<interrupt.h>
int main()
{
int main()
{
DDRC=0X00;
DDRB=0xff;
cli();
GICR|=(1<<INT0);
sei();
while(1)
{
PORTC=0xf7;
}
return 0;
}
ISR(INT0_VECT);
{
PORTB=0xff;
_delay_ms(500);
PORTB=0xff;
_delay_ms(500);
}

369-00667448
206E1

S-ar putea să vă placă și