Circuit:
Program:
#include<p18f452.h>
#pragma config WDT = OFF
void delay(unsigned int);
void main()
{
unsigned char led1[]={0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x3F};
unsigned char led2[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
unsigned char a,b;
TRISB=0x00;
TRISD=0x00;
PORTB=0b10111111;
PORTD=0b10111111;
while(1){
for(a=0;a<=9;a++)
{
PORTB=led2[a];
delay(200);
for(b=0;b<=9;b++)
{
delay(200);
PORTD=led1[b];
}
}
}
}
void delay (unsigned int time){
unsigned char i,j;
for(i=0;i<165;i++)
for(j=0;j<time;j++);
}
Program:
#include<p18f452.h>
#pragma config WDT = OFF
void delay(unsigned int);
void main()
{
unsigned char led1[]={0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x3F};
unsigned char led2[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
unsigned char a,b;
TRISB=0x00;
TRISD=0x00;
PORTB=0b10111111;
PORTD=0b10111111;
while(1){
for(a=0;a<=9;a++)
{
PORTB=led2[a];
delay(200);
for(b=0;b<=9;b++)
{
delay(200);
PORTD=led1[b];
}
}
}
}
void delay (unsigned int time){
unsigned char i,j;
for(i=0;i<165;i++)
for(j=0;j<time;j++);
}
Comments
Post a Comment