How to code an EKMC1601111 in arduino?

I can’t find any tools online and the datasheet was completely useless (unless I missed something). I thought my code would work but it doesn’t. Any help would be grateful. Thanks!

const int LED = 3;

void setup(){
  Serial.begin(9600);
  pinMode(LED, OUTPUT);
}

void loop(){
  int motion = analogRead(A0);
  Serial.println(motion);
  delay(1);
  if(motion< 1000){
    digitalWrite(LED, HIGH);
  }else{
    digitalWrite(LED, LOW);
  }
}

here is the datasheet: http://elcodis.com/parts/2241625/EKMC1601111.html#datasheet
And I am using a arduino Uno.

That appears to be a digital sensor. Why are you connecting it to an analog pin? The code does something, but you haven't explained what. You want it to do something, but you haven't explained what.

Oh okay. And I want to it to light an LED when I wave my hand over it. When I look at the serial monitor, all I see is ones even if I unplug the sensor.

You need to tell us how you have wired the sensor. Most likely, you've not wired a pullup or pulldown resistor, and you are not using the internal pullup resistor.

You need to tell us how you have wired the sensor. Most likely, you've not wired a pullup or pulldown resistor, and you are not using the internal pullup resistor.

Internal Pullup resistor? Can you link a site where I can learn all this? I thought that all I had to do was connect it to 5v and ground and connect to output to the arduino....

Bump.

Seriously need this help for a school project. :~

zaidinator: I thought that all I had to do was connect it to 5v and ground and connect to output to the arduino....

To get a reliable digital signal from it I had to include a high-value pulldown resistor on the signal line. I believe I used 51K?.

More details available here... http://arduino.cc/forum/index.php/topic,15736.0.html

To get a reliable digital signal from it I had to include a high-value pulldown resistor on the signal line. I believe I used 51K?.

More details available here... http://arduino.cc/forum/index.php/topic,15736.0.html

THANK YOU SO MUCH!!! :D You have probably just saved my project. I shall love you forever!

Hmmmm....I have added a pull down resistor but I still don't think it is working... It is randomly spitting out a one or zero.

Updated code:

const int LED = 3;
const int motion = 8;

void setup(){
  Serial.begin(9600);
  pinMode(LED, OUTPUT);
  pinMode(motion, INPUT);
}

void loop(){
  int readMotion = digitalRead(motion);
  Serial.println(readMotion);
  delay(500);
}

I want it to detect when my hand goes over it. I used a 20Kohm resistor for the pulldown.

Here is a quick video that I took with my iphone showing how I wired it up and what the serial monitor is telling me: http://www.youtube.com/watch?v=RsPRFE1sRSA

nevermind. I think it is working. Thanks everyone!