Using Serial.available() to break while loop
hello friends,
i'm trying exit infinite while loop when arduino receives new command python via serial. code essentially:
but though i'm sending things python, condition never met , loop never breaks. i've tried using non-infinite loop in order make sure sending python, , works expect, once infinite loop implemented, it's if nothing being sent.
i've tried:
perhaps can't checking new serial input inside while loop? suggestions appreciated!
i'm trying exit infinite while loop when arduino receives new command python via serial. code essentially:
code: [select]
while(!serial.available()) {
//do stuff
}
but though i'm sending things python, condition never met , loop never breaks. i've tried using non-infinite loop in order make sure sending python, , works expect, once infinite loop implemented, it's if nothing being sent.
i've tried:
code: [select]
while(1) {
//do stuff
if(serial.available() > 0) {
break; }
}
perhaps can't checking new serial input inside while loop? suggestions appreciated!
hi janizer, when reading serial (pseudocode follow);
hope helps : )
code: [select]
some_type result;
while (result not expect be){
while(serial.available()){
result = read serial
do stuff result if it's case
}
}
hope helps : )
Arduino Forum > Using Arduino > Programming Questions > Using Serial.available() to break while loop
arduino
Comments
Post a Comment