i've been using this code. removed the funcion bit because it was to many words
// DIGITAL MOTION SENSING STAIR LIGHTS
// Imran O Mumtaz
// Summer 2013
// Sources: ADAFRUIT LIBRARY, ARDUINO EXAMPLE CODE, ARDUINO FORUMS + (USER: JamesHayek) for some of the cool effects!
// Nested If statement suggested by Jessica Milne (CS 375)
// This system utilizes an Atmel Atmega 328p MCU along with 2 PIR (Pyroelectric infrared) Sensors (HC-SR501) and a Digital RGB LED strip (WS2811).
// One sensor placed at the bottom of the stairs (or where ever) and one at the top. Each sensor triggers a different animation (walking up or walking down) along with a shut down warning animation.
// Just modify the function calls in the void loop() and the actual functins towards the bottom area to change the animations, color, etc. colorWipe for example.
// The four parameters it takes are the RGB pixels followed by the speed at which you wish to run the animations. 0, 0, 0 would mean the LEDS are off and 255, 255, 255 means that they are all white/full brightness.
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_RGB Pixels are wired for RGB bitstream
// NEO_GRB Pixels are wired for GRB bitstream
// NEO_KHZ400 400 KHz bitstream (e.g. FLORA pixels)
// NEO_KHZ800 800 KHz bitstream (e.g. High Density LED strip)
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel strip = Adafruit_NeoPixel(380, 3, NEO_GRB + NEO_KHZ800);
int motionPin = 1; // PIR Input pin 8, UPSTAIRS
int motionPin2 = 7; // PIR 2 Input pin 7, DOWNSTAIRS
int senseMotion = 0; // variable to hold current state of motion detector
int senseMotion2 = 0; // 2nd variable for 2nd sensor
void setup() {
pinMode(motionPin, INPUT); //PIRs declared as inputs
pinMode(motionPin2, INPUT);
strip.begin();
strip.show(); // Initialize all pixels to 'off'
//rainbow (30000);
//rainbowCycle (30000);
//strip.show();
}
void loop() {
senseMotion = digitalRead (motionPin); //set variables equal to what our sensors are reading (on or off)
senseMotion2 = digitalRead (motionPin2);
if (senseMotion == HIGH || senseMotion2 == HIGH) { // Testing both sensors at same time, if high, go to apropriate line.
if (senseMotion2 == HIGH) { // If Upstairs motion sensor is triggered...
colorWipe (strip.Color (50, 50, 50), 1); // White/blue color sweep going up stairs (Towards the arrow on the strip)
strip.show(); // This being enabled or not, doesnt seem to make a difference. NVM it looks like its more responsive when trying to activate the PIRs one after another
delay (10000); // Wait so someone can get to the bottom or top of stairs, will remove this when 2nd sensor is implemented with an interrupt
//colorChase (strip.Color(255, 25, 25), 5); // Color chase animations, red, green, blue indicating that the light are about to shut down
//colorChase2(strip.Color(25, 255, 25), 5);
//colorChase (strip.Color(25, 25, 255), 5);
//scanner(200, 0, 255, 10);
colorWipe (strip.Color (0, 0, 0), 5); // This is needed for turn everything off, clear all pixels. More efficient with this here
strip.show();
}
if (senseMotion == HIGH) { // If motion sensor 2 (Downstairs) if high go to next line
colorWipe2 (strip.Color(50, 50, 50), 1);
strip.show();
delay(10000);
//colorChase (strip.Color(255, 25, 25), 15);
//colorChase2 (strip.Color(25, 255, 25), 5);
//colorChase (strip.Color(25, 25, 255), 5);
//scanner(200, 0, 255, 10);
colorWipe2 (strip.Color(0, 0, 0), 5);
strip.show();
}
}
else { // no motion = no lights or animate til off
digitalWrite (motionPin, LOW); //turning motion pins low, doesnt seem to make a difference either.
digitalWrite (motionPin2, LOW);
//colorWipe (strip.Color(0, 0, 0), 30);
strip.show();
}
}
}