Problem with HLRV-MaxSonar-EZ01

Hello !! I'm a french student.
But I have a problem to use a sensor with my arduino mega. :roll_eyes:
So with the HRLV-MaxSonar-EZ01, an ultrasonic sensor, I want to get a distance by a TTL signal. But I obtain random values.

My program :
byte distance;
const int impulsion = 10;

void setup ()
Serial2.begin(9600); //
Serial.begin (9600);
pinMode (distance, INPUT);
pinMode (impulsion, OUTPUT);

void loop ()

digitalWrite (impulsion, HIGH);//launch an impluse to start the echo
delayMicroseconds (21);
digitalWrite (impulsion, LOW);//stot the impulsion to stop the echo

distance = ();//get the distance
Serial.println (distance);//print the distance on the serial monitor

And I get values like 83, 53, 5 ... in firt I get 255 :astonished:

Informations about the ultrasonic sensor :

ultrason.ino (504 Bytes)