#include <avr/io.h>
#include<util/delay.h>
unsigned char arr[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
void main()
{
int i;
while(1)
{
DDRA=0XFF;
for(i=0;i<=7;i++)
{
PORTA=arr[i];
_delay_ms(1000);
}
}
}
#include<util/delay.h>
unsigned char arr[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
void main()
{
int i;
while(1)
{
DDRA=0XFF;
for(i=0;i<=7;i++)
{
PORTA=arr[i];
_delay_ms(1000);
}
}
}
In this we are taking..
unsigned char arr[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
means this is pin no in hex form.
Ex-
0B00000001= means PA0 of PORTA and in hex form this is 0x01.
0B00000010= means PA1 of PORTA and in hex form this is 0x02.
0B00000100= means PA2 of PORTA and in hex form this is 0x04.
0B00001000= means PA3 of PORTA and in hex form this is 0x08.
0B00010000= means PA4 of PORTA and in hex form this is 0x10.
0B00100000= means PA5 of PORTA and in hex form this is 0x20.
0B01000000= means PA6 of PORTA and in hex form this is 0x40.
0B10000000= means PA7 of PORTA and in hex form this is 0x80.
and due to 8 Pins so we have to take arr[i] = 0 to 7
No comments:
Post a Comment