Hi guys, I want to set up a circuit based around a dual element PIR sensor (D203S, datasheet here: http://www.electronikdreamz.com/data/sensor/d203s.pdf)
The idea is to be able to build a device with a servo in order to follow someone around a room. This is why I bought a dual element PIR sensor, in order to sense if the person is moving from left to right and vice versa, and to step the servo accordingly, following the person around the room by keeping them centralized in the sensor.
I assumed this could be done using analogRead in order to get a base number when nothing is in view of the sensor, and a higher(lower) number when someone is to the left of it, and a lower(higher) number when someone is to the right of it.
I don't seem to be seeing any change in value from the sensor though, could this be the code or the hardware wired up wrong?
Here is the code i am using:
int calibrationTime = 10;
int pirPin = A0;
int ledPin = 13;
int pirVal = 0;
void setup(){
Serial.begin(9600);
pinMode(pirPin, INPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(pirPin, LOW);
//give the sensor some time to calibrate
Serial.print("calibrating sensor ");
for(int i = 0; i < calibrationTime; i++){
Serial.print(".");
delay(1000);
}
Serial.println(" done");
Serial.println("SENSOR ACTIVE");
delay(50);
}
void loop(){
pirVal = analogRead(pirPin);
Serial.println(pirVal);
delay(200);
}
The code is very basic at the moment, this is just to test if I have wired the device up correctly, and to see the changes in values when I move my hand near it.
Am I doing something wrong?