Pages: [1]   Go Down
Author Topic: Problem with HLRV-MaxSonar-EZ01  (Read 358 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello !! I'm a french student.
But I have a problem to use a sensor with my arduino mega.  smiley-roll
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  smiley-eek

Informations about the ultrasonic sensor :

* ultrason.ino (0.49 KB - downloaded 6 times.)

Pages: [1]   Go Up
Jump to: