Documente Academic
Documente Profesional
Documente Cultură
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
================================================================================
=======================
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;
}
#include<avr/io.h>
#include<util/delay.h>
#define
#define
#define
#define
LCD_cntrl PORTD
rs PD0
rw PD1
en PD2
{
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
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);
}
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------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.
2.
3.
4.
wap
wap
wap
wap
to
to
to
to
================================================================================
=======================
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