Go Down

Topic: 2yoa21 sharp range finder returning values of 280-300 not responding. (Read 529 times) previous topic - next topic

samhallett

Hello I recently got my 2yoa21 sharp IR range finder but so far have been unable to return any accurate readings.I have tried many different bits of code , although all amount to the same. I have followed this tutorial to the letter ( i think) http://communityofrobots.com/tutorial/kawal/how-use-sharp-ir-sensor-arduino. and yet in My serial monitor I see a string of numbers varying between 280 and 300 ish regardless of objects being moved toward or away from the sensor. I have also checked my A0 pin on my leonardo with a potentiometer and it is working fine , does any one have any clues as to what the issue could be.

One explanation could be my wiring: the three wires coming from my range finder are respectively wound round the ends of three jumper wires (but not soldered) which I then insert into the various ports.

here is the code from the tutorial

Code: [Select]
int sensorpin = 0;                 // analog pin used to connect the sharp sensor
int val = 0;                 // variable to store the values from sensor(initially zero)

void setup()
{
  Serial.begin(9600);               // starts the serial monitor
}

void loop()
{
  val = analogRead(sensorpin);       // reads the value of the sharp sensor
  Serial.println(val);            // prints the value of the sensor to the serial monitor
  delay(300);                    // wait for this much time before printing next value
}


cheers

sam

Go Up