Good day! i am having trouble with Serial Communication. I wanted the serial monitor to print the value i sent but it also prints another value other than the one i sent. For example i send 1 it displays 1 and -38. Any help will be much appreciated! Thank You.
Here is my code:
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
int val = Serial.read()-"0";
// say what you got:
Serial.print("I received: ");
Serial.println(val);
}
}
Here is a screenshot of the serial monitor