Yeah sorry about that giant image, fixed it.
PIR Sensor (Panasonic AMN23111 Spot Sensor) : http://pewa.panasonic.com/assets/pcsd/catalog/napion-catalog.pdf
Ultrasonic Sensor (Maxbotix LV-EZ3) : http://maxbotix.com/documents/MB1030_Datasheet.pdf\
Simple test code:
#include <Adafruit_NeoPixel.h>
const int anPin = 4;
const int pirPin = 2;
float detectTime = 150.0;
float leaveTime = 600.0;
float presence = 0.0;
float noPresence = 0.0;
int calibrationTime = 3;
long anVolt, inches;
int sum=0;
int avgrange=60;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, 4, NEO_GRB + NEO_KHZ800);
void setup() {
//This opens up a serial connection to shoot the results back to the PC console
Serial.begin(9600);
strip.begin();
strip.show(); // Initialize all pixels to 'off'
pinMode(pirPin, INPUT);
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() {
for(int i = 0; i < avgrange ; i++)
{
anVolt = analogRead(anPin)/2;
sum += anVolt;
}
inches = sum/avgrange;
Serial.println(presence);
if(digitalRead(pirPin) == HIGH && inches <= 10.0){
presence++;
noPresence = 0.0;
if(presence >= detectTime) {
presence = 0.0;
colorFill(strip.Color(255, 0, 255));
}
}
if(digitalRead(pirPin) == LOW && inches >= 10.0){
noPresence++;
presence = 0.0;
if(noPresence >= leaveTime) {
noPresence = 0.0;
colorFill(strip.Color(0, 0, 0));
}
}
//reset sample total
sum = 0;
}
void colorFill(uint32_t color) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, color);
}
strip.show();
}