문제

i wrote simple arduino program to check a an array of ascii characters. Here is the program

void setup(){
  Serial.begin(9600); // connect serial

}

void loop(){

char inByte;
  char arr[100]={0};
  char arrr[5]={'s','t','a','r','t'};
 int x=0;
 int y=0;
  do{

    arr[x]=arrr[y];
    x++;
    y++;
      }while(arr[0]!='s' && arr[1] !='t' && arr[2]!='a' && arr[3]!='r' && arr[4]!='t');
  if(arr[0]=='s' && arr[1] =='t' && arr[2]=='a' && arr[3]=='r' && arr[4]=='t'){
    delay(1000);
    Serial.println("done");}
    else{
    delay(1000);
    Serial.println("oo");
}

}

I want it to show "done" in serial monitor but instead it is printing "oo"..can any one tell me what is the problem in the program..thanks

올바른 솔루션이 없습니다

다른 팁

open braces for else part also

if(arr[0]=='s' & arr[1] =='t' & arr[2]=='a' & arr[3]=='r' & arr[4]=='t'){
    delay(1000);
    Serial.println("done");
}
else {
    delay(1000);
    Serial.println("oo"); 
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top