I have a simple code.
void setup() {
Serial.begin(9600);
}
void loop() {
if(Serial.available()) {
char incomingChar = Serial.read();
char testChar = ".";
Serial.println(incomingChar);
Serial.println(incomingChar == testChar);
}
}
I opened serial monitor interface. I set baud to 9600 and "No line ending" and was typing: a
, b
, .
output is:
14:38:35.675 -> a
14:38:35.675 -> 0
14:38:37.105 -> b
14:38:37.105 -> 0
14:38:38.557 -> .
14:38:38.557 -> 0
Why char .
from serial port is not equal to .
?
You should change "."
to '.'
.
""
means string not a char