HC-SR04 Question Marks and random characters from reading

Hello everyone,

Just using this ultrasonic sensor for the first time and followed all the steps here http://playground.arduino.cc/Code/NewPing

All the pins are connected as showed in the example, but the serial monitor is just pushing question marks and random characters.

Anyone has any idea why is this happening?

Many thanks Joaquin

Anyone has any idea why is this happening?

Because the line speed set on your invisible code is different to the speed set on the serial monitor?

Hi many thanks for your quick answer,

it could be, I’m a just starting tbh. So, is there anyway I can fix it? Like creating a new variable to calculate the actual speed, or doing any operation within Serial.print(sonar.ping()); to convert the value to any other that would suit?

Many thanks in advance,
Joaquin

So, is there anyway I can fix it?

You can set the two bit rates to be the same. Does a simple "Hello world" sketch work as expected?

Edit: cannot -> can . Sorry.

If it's not related to sensors yes, but in this case for the ultrasonic sensor (using the code in the example), is not.

The example I tried is the one called "Sample NewPing Sketch" at http://playground.arduino.cc/Code/NewPing

Many thanks Joaquin

OK we need to see code, schematic, observations.

#include <NewPing.h>

#define TRIGGER_PIN 12
#define ECHO_PIN 11
#define MAX_DISTANCE 200

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

void setup() {
Serial.begin(115200);
}

void loop() {
delay(50);
Serial.print("Ping: ");
Serial.print(sonar.ping_cm());
Serial.println(“cm”);
}

Sorry this is the picture of the scheme https://goo.gl/images/sJjQ9K

Serial.begin(115200);

Is the number in the bottom-right corner of the serial monitor set to the same baud rate. Leo..

And that is what it was :), sorry if was something very basic but I have just started with this (and have no idea basically).

Many thanks again, Joaquin