jsureshp
Junior Member level 3
Actually i write a program for 7 segment display.
This coding working but in simulator not showing perfectly.
That means
not showing all at the same time.
one by one only showing.
I know my code was like that only written.
ok
I give my 7 segment coding....
anybody help to me for the right code.
#include<avr/io.h>
unsigned char i,c1=0,c2=0,c3=0;
unsigned char data[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
void display();
void delay();
int main()
{
DDRD=0xFF;
DDRC=0x0F;
while(1)
{
for(i=0;i<=10;i++)
{
if(i==10)
{
i=0;
c1++;
}
if(c1==10)
{
c1=0;
c2++;
}
if(c2==10)
{
c2=0;
c3++;
}
if(c3==10)
{
c3=0;
}
display();
}
}
}
void display()
{
PORTD=data;
PORTC=0x01;
PORTD=data;
delay();
PORTC=0x02;
PORTD=data[c1];
delay();
PORTC=0x04;
PORTD=data[c2];
delay();
PORTC=0x08;
PORTD=data[c3];
delay();
}
void delay()
{
unsigned char j;
for(j=0;j<5;j++);
}
Please Edit this code and give me a right code
This code for AVR Microcontroller
This coding working but in simulator not showing perfectly.
That means
not showing all at the same time.
one by one only showing.
I know my code was like that only written.
ok
I give my 7 segment coding....
anybody help to me for the right code.
#include<avr/io.h>
unsigned char i,c1=0,c2=0,c3=0;
unsigned char data[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
void display();
void delay();
int main()
{
DDRD=0xFF;
DDRC=0x0F;
while(1)
{
for(i=0;i<=10;i++)
{
if(i==10)
{
i=0;
c1++;
}
if(c1==10)
{
c1=0;
c2++;
}
if(c2==10)
{
c2=0;
c3++;
}
if(c3==10)
{
c3=0;
}
display();
}
}
}
void display()
{
PORTD=data;
PORTC=0x01;
PORTD=data;
delay();
PORTC=0x02;
PORTD=data[c1];
delay();
PORTC=0x04;
PORTD=data[c2];
delay();
PORTC=0x08;
PORTD=data[c3];
delay();
}
void delay()
{
unsigned char j;
for(j=0;j<5;j++);
}
Please Edit this code and give me a right code
This code for AVR Microcontroller