#include<avr/io.h>
#include<util/delay.h>
int arr[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void main()
{
int i;
while(1)
{
DDRA=0XFF;
DDRC=0X00;
if(PINC&0X01)
{
for(i=0;i<=9;i++)
{
PORTA=arr[i];
_delay_ms(1000);
}
}
else
{
PORTA=0X00;
}
}
}
In this we are using int arr[]={…………….}; means hex form of 0-9 on segment .
#include<util/delay.h>
int arr[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void main()
{
int i;
while(1)
{
DDRA=0XFF;
DDRC=0X00;
if(PINC&0X01)
{
for(i=0;i<=9;i++)
{
PORTA=arr[i];
_delay_ms(1000);
}
}
else
{
PORTA=0X00;
}
}
}
In this we are using int arr[]={…………….}; means hex form of 0-9 on segment .
format:-
0= 0x3F
1= 0X06
2 = 0X5B
3= 0X4F
4= 0X66
5= 0X6D
6= 0X7D
7= 0X07
8= 0X7F
9=0X6F
And for loop is using for complete the loop 0-9.
PINC&0X01 means PC0 is active high and by this way we
can make high any pin as a switch.
And according to this program we can write more for programs Like
as using 2 segments and two switch. Like as 1 segment using two switch. Using more
loops etc.
No comments:
Post a Comment