Help with Ultrasonic Sensor HC-SR04!

Hello!
Please, I need help with this code. Im perfectly sure that everything is well connected to the Arduino board.

The code :

#include "NewPing.h"

#define TRIGGER_PIN 3
#define ECHO_PIN 2
#define MAX_DISTANCE 200

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

// Right engine
int motorDer_C=8;
int motorDer_D=9;

//Left engine
int motorIzq_C=10;
int motorIzq_D=11;

int cm; //Variable

void Adelante(){
digitalWrite(motorIzq_C , HIGH);
digitalWrite(motorIzq_D , LOW);
digitalWrite(motorDer_C , HIGH);
digitalWrite(motorDer_D , LOW);
}
void Frenar(){
digitalWrite(motorIzq_C , LOW);
digitalWrite(motorIzq_D , LOW);
digitalWrite(motorDer_C , LOW);
digitalWrite(motorDer_D , LOW);
}

void DoblarI(){ // Turns left
digitalWrite(motorIzq_C , LOW);
digitalWrite(motorIzq_D , HIGH);
digitalWrite(motorDer_C , HIGH);
digitalWrite(motorDer_D , LOW);
}

void setup() {
pinMode(motorIzq_C, OUTPUT);
pinMode(motorIzq_D, OUTPUT);
pinMode(motorDer_C, OUTPUT);
pinMode(motorDer_D, OUTPUT);

Serial.begin (9600);

}

void loop() {
delay(50);
int cm = sonar.ping_cm();
Serial.print("Ping: ");
Serial.print(cm);
Serial.println("cm");

if (cm<=23){
Frenar();
DoblarI();
}

if (cm>23){
Frenar();
Adelante();
}
}

The problem is the following : In the serial monitor, while the distance is lower than 23, the sensor works just fine. But if the distance is bigger than 23 , the sensor goes crazy.

The problem lies on the conditional, not the distance. If I change 23cm for any other, the same thing happens.

Hope you can help, thank you!

the sensor goes crazy.

What do you mean by this ?
Please post an example of the crazy output.

Could it be electrical interference? Does the sensor "go crazy" in the same way when the motors are disconnected?

Sorry that I expressed that way.
I meant that the sensor throws nonsence values. Like, my hand is 30 cm away, and throws : 3cm,15cm,70cm,4cm,6cm, things like that, while my hand stands still 30 away (So, random numbers).
(Sorry for my english, not my first language)

I discarted electrical interference because I have the sensor on my other hand, away from the "noise of the motors".

If Im sure of one thing, is that the problem is that, the motors. If I only use one, it works perfectly...

Does it work OK if you disconnect the motors ?
How are the motors powered ?
How are the motors wired and connected to the Arduino ?

Cut out all the motor stuff, and put a simple 10Hz range measurement cycle in "loop()".
Print the range to a solid target, normal to the sensor.