ASSIGNMENT 1 -CONTROLLING LEDs
questions:
- GLOW A SINGLE LED
- GLOW 8 LED OF A PORT
- BLINKING A SINGLE LED
- BLINKING 8 LED OF A PORT
- ALTERNATE GLOWING LED s
- GLOWING LED IN INCREASING PATTERN
- GLOWING LED IN DECREASING PATTERN
- GLOWING LED IN CONVERGING PATTERN
- GLOWING LED IN DIVERGING PATTERN
- BOTH CONVERGING AND DIVERGING PATTERN
- INCREASING AND DECREASING PATTERN
- WITH A SWITCH GLOW 1 LED
- WITH A SWITCH GLOW ALL 8 LEDS
- WITH 4 DIFFERENT SWITCH GLOW 4 DIFFERENT PATTERN
- WITH 1 SWITCH GLOW 4 DIFFERENT PATTERN
_______________________________________________________________________________
answers:
GLOW A SINGLE LED
DDRA.0=1;
while (1)
{
PORTA.0=1;
};
}
_______________________________________________________________________________
DDRA.0=255;
while (1)
{
PORTA=255;
};
}
_______________________________________________________________________________
BLINKING A SINGLE LED
DDRA.0=1;
// declaring pin as output
while (1)
{
PORTA.0=1; // giving output to pin as 5 volt
delay_ms(100); // dont forget
to include header file #include<delay.h>
PORTA.0=0;
delay_ms(100);
};
}
_______________________________________________________________________________
DDRA=255;
// declaring port as output
while (1)
{
PORTA=255; // giving output to pin as 5 volt
delay_ms(100); // dont forget
to include header file #include<delay.h>
PORTA=0;
delay_ms(100);
};
}
_______________________________________________________________________________
DDRA=255;
// declaring port as output
while (1)
{
PORTA=0b01010101; // giving value in binary format
delay_ms(100); //
dont forget to include header file #include<delay.h>
PORTA=0b10101010;
delay_ms(100);
};
}
_______________________________________________________________________________
// do not forget to initialize x as an integer (int x) above main() on top of program
We have to make pattern in binary form like this
00000001
00000011
00000111
00001111
00011111
00111111
01111111
11111111
All places having 1 denotes led glow ie +5V while 0 stands
for o volt
while (1)
{
for(x=1;x<256;x=((x*2)+1))
{
PORTA=x;
delay_ms(100);
}
};
}
_______________________________________________________________________________
Decreasing pattern : DO IT YOURSELF
_______________________________________________________________________________
// do not forget to initialize x,y as an integer (int
x,y;) above main() on top of program
We have to make pattern in binary form like this
10000001
01000010
00100100
00011000
DDRA=255;
// declaring port as output
while (1)
{ y=1; // DECLARE
int y,x; ON THE TOP OF PROGRAM
for(x=128;x>=16;x=x/2)
// do not forget to intialise x as an integer (int x) above main() on
top of program
{
PORTA=x+y;
y=y*2;
delay_ms(100);
}
};
}
_______________________________________________________________________________
// do not forget to initialize x,y as an integer (int
x,y;) above main() on top of program
We have to make pattern in binary form like this
00011000
00100100
01000010
10000001
DDRA=255;
// declaring port as output
while (1)
{ y=8; // DECLARE
int y,x; ON THE TOP OF PROGRAM
for(x=16;x<=128;x=x*2)
// do not forget to intialise x as an integer (int x) above main() on
top of program
{
PORTA=x+y;
y=y/2;
delay_ms(100);
}
};
}
Converging and diverging pattern:
do it yourself
_______________________________________________________________________________
DDRA.0=1;
//PIN A AS OUTPUT
DDRB.0=0; //
PIN B AS INPUT
while (1)
{
if(PINB.0==1) // IF PIN B
GETS INPUT 5 V FROM SWITCH PIN A IS GIVEN 5 V
{
PORTA.0=1;
}
};
}
This comment has been removed by a blog administrator.
ReplyDeleteIs it real that you are pursuing down the LED TV Service Center in Hyderabad Electronicservicecenter.in is one of the fundamental multi check advantage center in twin urban areas. We have been advancing strong and quality affiliations wherever all through the city with our inside and out readied and fit bosses.
ReplyDelete