Go Down

Topic: Infrared - Sharp 2D120X problem please help me (Read 1 time) previous topic - next topic

Hello, I am so frustrated on trying to make this thing work. I'm Newbie! Please correct me.
there are 3 color of wire, red wire to 5v, yellow to A1 (analog), black to ground.
I got this as the result:

100
6
45
108
123
37
0
0
15
79
128
104
8
0




Code: [Select]
//Reads and analog sensor and displays the value
int sensePin = 7;

void setup()
{
  //Note: We don't need to specifiy sensePin as an
  //input, since it defaults to that when we read it

  //This is the default value, but we can set it anyways
  analogReference(DEFAULT); //5V Reference on UNO
 
  //Allows us to listen to serial communications from the arduino
  Serial.begin(9600);
}

void loop()
{
  // print the button state to a serial terminal
  Serial.println(analogRead(A1));
  delay(500);
  //wait half a second, then print again.
}



Grumpy_Mike

Looks like you haven't wired it up correctly. Is the ground connected? Is the power connected to the sensor?

For best help provide a link to the sensor's data sheet.

There is 3 wire, black on the left, red in the middle, yellow on the right. black connect to Ground, red to 5v., yellow to A0.

Grumpy_Mike

The data sheet says to connect a 47uF capacitor across the supply as close to the sensor as you can get. Try that.

Go Up