xvx
June 8, 2023, 8:14pm
1
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial.available()){
Serial.println(Serial.readString() =='stop');
}
}
Why the output is always 1, no matter the content I typed in ? it should be 0 right, if the input is not stop.
xvx:
'stop'
Single quotes?
How does that work?
xvx
June 8, 2023, 8:16pm
3
but if i changes to "", even the input is stop, the output is still 0.
xvx:
the output is still 0.
Which?
What is the line ending setting on the serial monitor?
xvx
June 8, 2023, 8:19pm
5
The result I am expected is that when I enter stop in the serial monitor, the value of Serial.readString() =='stop' should be zero.
Can you explain your expectations, please?
What is the line-ending setting in the serial monitor?
I think I may have already asked.
probably getting a newline in the string..
try..
Serial.println(Serial.readString() =="stop\n");
good luck.. ~q
1 Like
then maybe..
Serial.println(!Serial.readString() =="stop\n");
happy trails.. ~q
1 Like
...or you could take the hint, and change the line-ending setting in the serial monitor.
1 Like
system
Closed
December 5, 2023, 8:48pm
12
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.