Code như sau
#include <REG52.H>
void delay_ms(unsigned char n)
{
unsigned char i,j;
for(i=0;i<n;i++){
for(j=0;j<120;j++){}
}
}
void main(){
// khai báo các bien dem hieu ung
unsigned char i=0;
unsigned char j=0;
unsigned char x=0;
//chay duong vien
unsigned char code border[]={0xFE,0xFD,0xFB,0xF7,0xEF};
unsigned char code effectP0[]={0xFF,0x00,0xFF,0x00,0xFE,0xFD,0xFB,0xF7,0xEF,0xD F,0xBF,0x7F,0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xF E,
0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F,0x7F,0xBF, 0xDF,0xEF,0xF7,0xFB,0xFD,0xFE};
unsigned char code effectP2[]={0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE,0x7E,0xB E,0xDE,0xEE,0xF6,0xFA,0xFC,0x7C,0xBC,0xDC,0xEC,
0xF4,0xF8,0x78,0xB8,0xD8,0xE8,0xF0,0x70,0xB0,0xD0, 0xE0,0x60,0xA0,0xC0,0x40,0x80,0x00,0xFE,0xFD,0xFB,
0xF7,0xEF,0xDF,0xBF,0x7F,0x7F,0xBF,0xDF,0xEF,0xF7, 0xFB,0xFD,0xFE,0x55,0xAA,0x55,0xAA,0x55,0xAA,0xFF,
0xFF,0xFF,0x55,0xAA,0x55,0xAA,0x55,0xFF,0xFF};
while(1){
if(i<sizeof(effectP2)){
P2=~effectP2[i];
i++;
}else{
i=0;
}
if(j<sizeof(effectP0)){
P0=~effectP0[j];
j++;
}else{
j=0;
}
delay_ms(400);
if(x<sizeof(border)){
P1=~border[x];
x++;
}else{
x=0;
}
delay_ms(800);
}
}
anh ơi e dịch bằng kiel nó báo lỗi nay nè a:
C++.C(29): error C141: syntax error near ')'
C++.C(32): error C141: syntax error near 'else'
C++.C(34): error C141: syntax error near '}'
C++.C(36): error C141: syntax error near '<', expected ')'
C++.C(36): error C129: missing ';' before ')'
Target not created
while(1){
if(i<sizeof(effectP2)){
P2=~effectP2[i];
i++;
}else{
i=0;
}
lệnh này e hok hiểu "sizeof"
mong a hồi âm sớm.
#include <REG52.H>
void delay_ms(unsigned char n)
{
unsigned char i,j;
for(i=0;i<n;i++){
for(j=0;j<120;j++){}
}
}
void main(){
// khai báo các bien dem hieu ung
unsigned char i=0;
unsigned char j=0;
unsigned char x=0;
//chay duong vien
unsigned char code border[]={0xFE,0xFD,0xFB,0xF7,0xEF};
unsigned char code effectP0[]={0xFF,0x00,0xFF,0x00,0xFE,0xFD,0xFB,0xF7,0xEF,0xD F,0xBF,0x7F,0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xF E,
0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F,0x7F,0xBF, 0xDF,0xEF,0xF7,0xFB,0xFD,0xFE};
unsigned char code effectP2[]={0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE,0x7E,0xB E,0xDE,0xEE,0xF6,0xFA,0xFC,0x7C,0xBC,0xDC,0xEC,
0xF4,0xF8,0x78,0xB8,0xD8,0xE8,0xF0,0x70,0xB0,0xD0, 0xE0,0x60,0xA0,0xC0,0x40,0x80,0x00,0xFE,0xFD,0xFB,
0xF7,0xEF,0xDF,0xBF,0x7F,0x7F,0xBF,0xDF,0xEF,0xF7, 0xFB,0xFD,0xFE,0x55,0xAA,0x55,0xAA,0x55,0xAA,0xFF,
0xFF,0xFF,0x55,0xAA,0x55,0xAA,0x55,0xFF,0xFF};
while(1){
if(i<sizeof(effectP2)){
P2=~effectP2[i];
i++;
}else{
i=0;
}
if(j<sizeof(effectP0)){
P0=~effectP0[j];
j++;
}else{
j=0;
}
delay_ms(400);
if(x<sizeof(border)){
P1=~border[x];
x++;
}else{
x=0;
}
delay_ms(800);
}
}
anh ơi e dịch bằng kiel nó báo lỗi nay nè a:
C++.C(29): error C141: syntax error near ')'
C++.C(32): error C141: syntax error near 'else'
C++.C(34): error C141: syntax error near '}'
C++.C(36): error C141: syntax error near '<', expected ')'
C++.C(36): error C129: missing ';' before ')'
Target not created
while(1){
if(i<sizeof(effectP2)){
P2=~effectP2[i];
i++;
}else{
i=0;
}
lệnh này e hok hiểu "sizeof"
mong a hồi âm sớm.
Comment