Thank you for information,
here is the code, I had to make it a little bit shorter, I tried to attach it like now but I had error about exceeding the maximum allowed length, could you tell me something more now?
#include <Adafruit_NeoPixel.h>
#include <IRremote.h>
#define PIN 6
#define NUM_LEDS 150
#define receiver 9 // IR receiver pin
#define BUTTON_C 0xFFFFFFFF
#define BUTTON_1 0xFFA25D
#define BUTTON_2 0xFF629D
// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel. Avoid connecting
// on a live circuit...if you must, connect GND first.
// Set up Variables
unsigned long timeOut=60000; // timestamp to remember when the PIR was triggered.
int downUp = 0; // variable to rememer the direction of travel up or down the stairs
int alarmPinTop = 11; // PIR at the top of the stairs
int alarmPinBottom =11; // PIR at the bottom of the stairs
int alarmValueTop = LOW; // Variable to hold the PIR status
int alarmValueBottom = LOW; // Variable to hold the PIR status
int ledPin = 13; // LED on the arduino board flashes when PIR activated
int LDRSensor = A0; // Light dependant resistor
int LDRValue = 0; // Variable to hold the LDR value
int colourArray[350]; // An array to hold RGB values
int change = 1; // used in 'breathing' the LED's
int breathe = 0; // used in 'breathing' the LED's
IRrecv irrecv(receiver); //create a new instance of receiver
decode_results results;
unsigned long lastCode;
void setup() {
strip.begin();
strip.setBrightness(50); //adjust brightness here
strip.show(); // Initialize all pixels to 'off'
Serial.begin (9600); // only requred for debugging
pinMode(ledPin, OUTPUT); // initilise the onboard pin 13 LED as an indicator
pinMode(alarmPinTop, INPUT_PULLUP); // for PIR at top of stairs initialise the input pin and use the internal restistor
pinMode(alarmPinBottom, INPUT_PULLUP); // for PIR at bottom of stairs initialise the input pin and use the internal restistor
pinMode(receiver, INPUT_PULLUP);
irrecv.enableIRIn(); //start the receiver
delay (2000); // it takes the sensor 2 seconds to scan the area around it before it can detect infrared presence
}
void loop() {
if (irrecv.decode(&results)) { //we have received an IR code
Serial.println(results.value, HEX);
irrecv.resume();
}
translateIR();
}
void translateIR() {
switch (results.value) {
case BUTTON_1:
stairs();
break;
case BUTTON_2:
blueWhiteChase();
break;
case BUTTON_C:
results.value = lastCode;
break;
default:
stairs();
break;
}
delay(0);
}
void stairs() {
LDRValue = analogRead(LDRSensor);
//Serial.println(LDRValue);
if (LDRValue > 600) { // only switch on LED's at night when LDR senses low light conditions - you may have to change the number for your circumstances!
if (timeOut+15700 < millis()) { // idle state - 'breathe' the top and bottom LED to show program is looping
uint32_t blue = (0, 0, breathe);
breathe = breathe + change;
strip.setPixelColor(0, blue);
strip.setPixelColor(34, blue);
strip.setPixelColor(35, blue);
strip.setPixelColor(69, blue);
strip.show();
if (breathe == 100 || breathe == 0) change = -change; // breathe the LED from 0 = off to 100 = fairly bright
if (breathe == 100 || breathe == 0); delay (50); // Pause at beginning and end of each breath
delay(10);
}
alarmValueTop = digitalRead(alarmPinTop); // Constantly poll the PIR at the top of the stairs
//Serial.println(alarmPinTop);
alarmValueBottom = digitalRead(alarmPinBottom); // Constantly poll the PIR at the bottom of the stairs
//Serial.println(alarmPinBottom);
if (alarmValueTop == HIGH && downUp != 2) { // the 2nd term allows timeOut to be contantly reset if one lingers at the top of the stairs before decending but will not allow the bottom PIR to reset timeOut as you decend past it.
timeOut=millis(); // Timestamp when the PIR is triggered. The LED cycle wil then start.
downUp = 1;
//clearStrip();
topdown(); // lights up the strip from top down
}
if (alarmValueBottom == HIGH && downUp != 1) { // the 2nd term allows timeOut to be contantly reset if one lingers at the bottom of the stairs before decending but will not allow the top PIR to reset timeOut as you decend past it.
timeOut=millis(); // Timestamp when the PIR is triggered. The LED cycle wil then start.
downUp = 2;
//clearStrip();
bottomup(); // lights up the strip from bottom up
}
if (timeOut+10000 < millis() && timeOut+15000 < millis()) { //switch off LED's in the direction of travel.
if (downUp == 1) {
colourWipeDown(strip.Color(0, 0, 0), 100); // Off
}
if (downUp == 2) {
colourWipeUp(strip.Color(0, 0, 0), 100); // Off
}
downUp = 0;
}
}
else if (LDRValue < 600) {
colourWipeUp(strip.Color(0, 0, 0), 100);
}
}
void topdown() {
Serial.println ("detected top"); // Helpful debug message
colourWipeDown(strip.Color(255, 241, 224), 25 ); // Warm White
//for(int i=0; i<3; i++) { // Helpful debug indication flashes led on Arduino board twice
//digitalWrite(ledPin,HIGH);
//delay(200);
//digitalWrite(ledPin,LOW);
//delay(200);
//}
}
void bottomup() {
Serial.println ("detected bottom"); // Helpful debug message
colourWipeUp(strip.Color(255, 241, 224), 25); // Warm White
//for(int i=0; i<3; i++) { // Helpful debug indication flashes led on Arduino board twice
//digitalWrite(ledPin,HIGH);
//delay(200);
//digitalWrite(ledPin,LOW);
//delay(200);
//}
}
// Fade light each step strip
void colourWipeDown(uint32_t c, uint16_t wait) {
for (uint16_t j = 0; j < 15; j++){
int start = strip.numPixels()/15 *j;
Serial.println(j);
for (uint16_t i = start; i < start + 35; i++){
strip.setPixelColor(i, c);
}
strip.show();
delay(wait);
}
}
void clearStrip(){
for (int l=0; l<strip.numPixels(); l++){
strip.setPixelColor(l, (0,0,0));
}
}
// Fade light each step strip
void colourWipeUp(uint32_t c, uint16_t wait) {
for (uint16_t j = 15; j > 0; j--){
int start = strip.numPixels()/15 *j;
Serial.println(j);
//start = start-1;
for (uint16_t i = start; i > start - 35; i--){
strip.setPixelColor(i-1, c);
}
strip.show();
delay(wait);
}
}
void blueWhiteChase() {
static int i = 0;
for (int j = -5; j < 150; j = j + 6) {
if (j+i < 0);
strip.setPixelColor(j+i, 0, 0, 30);
strip.setPixelColor(j+i+1, 0, 0, 100);
strip.setPixelColor(j+i+2, 0, 0, 255);
strip.setPixelColor(j+i+3, 30, 30, 30);
strip.setPixelColor(j+i+4, 90, 90, 90);
strip.setPixelColor(j+i+5, 180, 180, 180);
}
strip.show();
i = (i+1)%600;
}