Hello there.
I'm just a noob at electronics. This is very literally my first morning using an Arduino and doing anything electronics related.
Having said that I do have a programming background so I'm not completely lost.
Now that you know who you're dealing with... here's what I'm trying to do.
Project Description:
I have an Arduino UNO and a Sharp GP2Y0A02YK0F Distance Sensor. I downloaded the following library (and imported): GitHub - jeroendoggen/Arduino-GP2Y0A21YK-library: Arduino library for the Sharp GP2Y0A21YK IR Distance sensor
This is the code that I have in my sketch: (based on an example that's included with the library)
#include <DistanceGP2Y0A21YK.h>
//#include <DistanceGP2Y0A21YK_LUTs.h>
DistanceGP2Y0A21YK DistanceSensor;
int distance;
void setup() {
// put your setup code here, to run once:
// this is where you initialize your hardware and get it ready for operation.
Serial.begin(9600); //defining the speed of the serial communications
DistanceSensor.begin(0);
}
void loop() {
// put your main code here, to run repeatedly: (until the arduino is reset or powered off)
distance = DistanceSensor.getDistanceCentimeter();
Serial.print("\nDistance in centimers: ");
Serial.print(distance);
delay(500); //make it readable
}
Problem:
I'm not confident that the data I'm getting back is accurate. Reason being, right now, I have it lying on it's back facing up towards my ceiling as I program it. I keep getting values ranging from 9-14 cms.
If I cover both lenses with a stack of paper or my fingers I still get a similar range back.
I'm wondering if I've set this thing up correctly?
I have some pictures of my breadboard / Arduino set up. I've attached it below.
Basic Description of Breadboard setup:
Incase it's not clear from the picture, the distance sensor has 3 wires, yellow, black and red. the yellow is what i'm assuming is sending the voltage data... and that is being passed into input A0 on my Arduino. The rest of the wires I have is to the the power from the Arduino and supply it to the sensor.
If you need more details about the breadboard set up please just let me know.
Thanks.
