Areeha Durrani
- Jul 8, 2015
- 45
- Joined
- Jul 8, 2015
- Messages
- 45
hello,i am new to avr and stuck at a point.My task is to do is turn on LEDs(ON LED BAR) one by one in forward direction (example 10000000,11000000,11100000).
But the code that i am writing turns the leds on in a pattern (1000000,01000000,00100000..).kindly help me with this.
my code is:
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
DDRB=0XFF;
PORTB=0XFF;
int i;
for(i=0;i<=8;i++)
{
PORTB=(1<<i);
_delay_ms(500);
}
return 0;
}
But the code that i am writing turns the leds on in a pattern (1000000,01000000,00100000..).kindly help me with this.
my code is:
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
DDRB=0XFF;
PORTB=0XFF;
int i;
for(i=0;i<=8;i++)
{
PORTB=(1<<i);
_delay_ms(500);
}
return 0;
}