#include <REGX52.H>
sbit led1=P2^0;
sbit led2=P2^1;
sbit led3=P2^2;
sbit led4=P2^3;
sbit led5=P2^4;
sbit led6=P2^5;
sbit led7=P2^6;
sbit led8=P2^7;
sbit key1=P3^2;
sbit key2=P3^3;
sbit key3=P3^4;
sbit key4=P3^5;
sbit key5=P3^6;
sbit key6=P3^7;
char dem;
char cong4;
void demled()
{
if (key1==0) {if (cong4==1) dem=5; else dem=1;cong4=0;While(key1==0);}
if (key2==0) {if (cong4==1) dem=6; else dem=2;cong4=0;While(key2==0);}
if (key3==0) {if (cong4==1) dem=7; else dem=3;cong4=0;While(key3==0);}
if (key4==0) {if (cong4==1) dem=8; else dem=4;cong4=0;While(key4==0);}
if (key5==0) {cong4=1;dem=0;While(key5==0);}
}
void dieukhienled()
{
if(key6==0)
{
if (demled==1) led1=!led1; // neu dem=1 thi dao trang thai cua led1
if (demled==2) led2=!led2; // neu dem=2 thi dao trang thai cua led2
if (demled==3) led3=!led3; // neu dem=3 thi dao trang thai cua led3
if (demled==4) led4=!led4; // neu dem=4 thi dao trang thai cua led4
if (demled==5) led5=!led5; // neu dem=5 thi dao trang thai cua led5
if (demled==6) led6=!led6; // neu dem=6 thi dao trang thai cua led6
if (demled==7) led7=!led7; // neu dem=7 thi dao trang thai cua led7
if (demled==8) led8=!led8; // neu dem=8 thi dao trang thai cua led8
dem=0;
cong4=0;
while(key6==0);
}
}
void main(void)
{
while(1)
{
demled();
dieukhienled();
}
}
nó báo lỗi dòng thứ 23 dưới chỗ void demled() ấy mà mình k phát hiện ra là lỗi gì.
sbit led1=P2^0;
sbit led2=P2^1;
sbit led3=P2^2;
sbit led4=P2^3;
sbit led5=P2^4;
sbit led6=P2^5;
sbit led7=P2^6;
sbit led8=P2^7;
sbit key1=P3^2;
sbit key2=P3^3;
sbit key3=P3^4;
sbit key4=P3^5;
sbit key5=P3^6;
sbit key6=P3^7;
char dem;
char cong4;
void demled()
{
if (key1==0) {if (cong4==1) dem=5; else dem=1;cong4=0;While(key1==0);}
if (key2==0) {if (cong4==1) dem=6; else dem=2;cong4=0;While(key2==0);}
if (key3==0) {if (cong4==1) dem=7; else dem=3;cong4=0;While(key3==0);}
if (key4==0) {if (cong4==1) dem=8; else dem=4;cong4=0;While(key4==0);}
if (key5==0) {cong4=1;dem=0;While(key5==0);}
}
void dieukhienled()
{
if(key6==0)
{
if (demled==1) led1=!led1; // neu dem=1 thi dao trang thai cua led1
if (demled==2) led2=!led2; // neu dem=2 thi dao trang thai cua led2
if (demled==3) led3=!led3; // neu dem=3 thi dao trang thai cua led3
if (demled==4) led4=!led4; // neu dem=4 thi dao trang thai cua led4
if (demled==5) led5=!led5; // neu dem=5 thi dao trang thai cua led5
if (demled==6) led6=!led6; // neu dem=6 thi dao trang thai cua led6
if (demled==7) led7=!led7; // neu dem=7 thi dao trang thai cua led7
if (demled==8) led8=!led8; // neu dem=8 thi dao trang thai cua led8
dem=0;
cong4=0;
while(key6==0);
}
}
void main(void)
{
while(1)
{
demled();
dieukhienled();
}
}
nó báo lỗi dòng thứ 23 dưới chỗ void demled() ấy mà mình k phát hiện ra là lỗi gì.
Comment