Matching baud rate on serial monitor
If your sketch has

  ...
void setup() {
  Serial.begin(115200);
  // ... other stuff here;
}
  ...


And you run the IDE serial monitor at 9600, you will get gibberish. The same happens the other way round. You need to match the monitor to the baud rate you've defined on the Serial.begin(); call.