bác nào cao tay chỉ giúp em sửa cái code này cho nó quét cùng lúc 4 led với..........em mới học nên chưa biết nhiều ạ
code đây ạ
#include <16f877a.h>
#fuses XT,HS,NOWDT,PUT
#use delay(clock=4000000)
#use fast_IO(a)
#use fast_IO(d)
#use fast_io(c)
#byte portd=0x08
#byte portc=0x06
#bit RA0=0x05.0
#bit RA1=0x05.1
#bit RA2=0x05.2
#bit RA3=0x05.3
int u[10]={0b11000000,0b11111001,0b10100100,0b10110000,0b10 011001,0b10010010,0b10000010,0b11111000,0b10000000 ,0b10010000};
signed int x,i,y,z,n,m,l;
int chuc,donvi,chuc1,donvi1,chuc2,donvi2,chuc4,donvi4, chuc5,donvi5,chuc6,donvi6;
void main()
{
set_tris_a(0b0000);
set_tris_d(0);
set_tris_c(0b00000000);
while(true)
{ x=30;
y=27;
z=3;
n=27;
m=3;
l=30;
//----------cot1---------
//---------------do1--------------
while(x>=0)
{
output_c(0b00000100);
chuc=x/10;
donvi=x%10;
for(i=0;i<50;i++)
{
portd=u[chuc];
RA0=0;
delay_ms(5);
RA0=1;
portd=u[donvi];
RA1=0;
delay_ms(5);
RA1=1;
}
x--;
output_c(0b00000000);
}
//--------------xanh1-----------
while(y>=0)
{
output_c(0b00000010);
chuc1=y/10;
donvi1=y%10;
for(i=0;i<50;i++)
{
portd=u[chuc1];
RA0=0;
delay_ms(5);
RA0=1;
portd=u[donvi1];
RA1=0;
delay_ms(5);
RA1=1;
}
y--;
output_c(0b00000000);
}
//--------vang1--------
while(z>=0)
{
output_c(0b01000000);
chuc2=z/10;
donvi2=z%10;
for(i=0;i<50;i++)
{
portd=u[chuc2];
RA0=0;
delay_ms(5);
RA0=1;
portd=u[donvi2];
RA1=0;
delay_ms(5);
RA1=1;
}
z--;
output_c(0b00000000);
}
//----------cot2---------------------
//----------xanh2----------------
while(n>=0)
{
output_c(0b00100000);
chuc4=n/10;
donvi4=n%10;
for(i=0;i<50;i++)
{
portd=u[chuc4];
RA2=0;
delay_ms(5);
RA2=1;
portd=u[donvi4];
RA3=0;
delay_ms(5);
RA3=1;
}
n--;
output_c(0b00000000);
}
//-----------vang2--------------
while(m>=0)
{
output_c(0b00010000);
chuc5=m/10;
donvi5=m%10;
for(i=0;i<50;i++)
{
portd=u[chuc5];
RA2=0;
delay_ms(5);
RA2=1;
portd=u[donvi5];
RA3=0;
delay_ms(5);
RA3=1;
}
m--;
output_c(0b00000000);
}
//------do2-----------------
while(l>=0)
{
output_c(0b00001000);
chuc6=l/10;
donvi6=l%10;
for(i=0;i<50;i++)
{
portd=u[chuc6];
RA2=0;
delay_ms(5);
RA2=1;
portd=u[donvi6];
RA3=0;
delay_ms(5);
RA3=1;
}
l--;
output_c(0b00000000);
}
}
}
code đây ạ
#include <16f877a.h>
#fuses XT,HS,NOWDT,PUT
#use delay(clock=4000000)
#use fast_IO(a)
#use fast_IO(d)
#use fast_io(c)
#byte portd=0x08
#byte portc=0x06
#bit RA0=0x05.0
#bit RA1=0x05.1
#bit RA2=0x05.2
#bit RA3=0x05.3
int u[10]={0b11000000,0b11111001,0b10100100,0b10110000,0b10 011001,0b10010010,0b10000010,0b11111000,0b10000000 ,0b10010000};
signed int x,i,y,z,n,m,l;
int chuc,donvi,chuc1,donvi1,chuc2,donvi2,chuc4,donvi4, chuc5,donvi5,chuc6,donvi6;
void main()
{
set_tris_a(0b0000);
set_tris_d(0);
set_tris_c(0b00000000);
while(true)
{ x=30;
y=27;
z=3;
n=27;
m=3;
l=30;
//----------cot1---------
//---------------do1--------------
while(x>=0)
{
output_c(0b00000100);
chuc=x/10;
donvi=x%10;
for(i=0;i<50;i++)
{
portd=u[chuc];
RA0=0;
delay_ms(5);
RA0=1;
portd=u[donvi];
RA1=0;
delay_ms(5);
RA1=1;
}
x--;
output_c(0b00000000);
}
//--------------xanh1-----------
while(y>=0)
{
output_c(0b00000010);
chuc1=y/10;
donvi1=y%10;
for(i=0;i<50;i++)
{
portd=u[chuc1];
RA0=0;
delay_ms(5);
RA0=1;
portd=u[donvi1];
RA1=0;
delay_ms(5);
RA1=1;
}
y--;
output_c(0b00000000);
}
//--------vang1--------
while(z>=0)
{
output_c(0b01000000);
chuc2=z/10;
donvi2=z%10;
for(i=0;i<50;i++)
{
portd=u[chuc2];
RA0=0;
delay_ms(5);
RA0=1;
portd=u[donvi2];
RA1=0;
delay_ms(5);
RA1=1;
}
z--;
output_c(0b00000000);
}
//----------cot2---------------------
//----------xanh2----------------
while(n>=0)
{
output_c(0b00100000);
chuc4=n/10;
donvi4=n%10;
for(i=0;i<50;i++)
{
portd=u[chuc4];
RA2=0;
delay_ms(5);
RA2=1;
portd=u[donvi4];
RA3=0;
delay_ms(5);
RA3=1;
}
n--;
output_c(0b00000000);
}
//-----------vang2--------------
while(m>=0)
{
output_c(0b00010000);
chuc5=m/10;
donvi5=m%10;
for(i=0;i<50;i++)
{
portd=u[chuc5];
RA2=0;
delay_ms(5);
RA2=1;
portd=u[donvi5];
RA3=0;
delay_ms(5);
RA3=1;
}
m--;
output_c(0b00000000);
}
//------do2-----------------
while(l>=0)
{
output_c(0b00001000);
chuc6=l/10;
donvi6=l%10;
for(i=0;i<50;i++)
{
portd=u[chuc6];
RA2=0;
delay_ms(5);
RA2=1;
portd=u[donvi6];
RA3=0;
delay_ms(5);
RA3=1;
}
l--;
output_c(0b00000000);
}
}
}
Comment