Vinz68 / stairsJs

nodeJS program for RPI-3 to automatically drive stairs LED lights, using PIR detection.
3 stars 1 forks source link

Vraag #1

Closed Kolk123 closed 5 years ago

Kolk123 commented 5 years ago

Ik heb een vraag. aan je naam te zien gok ik dat je nederlands bent. ik heb een trap met 16 ws2812b ledstrips a36 led per tree . mijn doel was om met een arduino mijn leds aan te sturen samen met 2 PIR sensoren. helaas krijg ik dit allemaal niet werkend. zou jij mij kunnen vertellen of jou software mij daarbij kan helpen? en op werkte trigger heb jij de sensoren aangesloten?

Groetjes Roy Kolk

Vinz68 commented 5 years ago

Hallo Roy,

Klopt, ben Nederlander ?? Ik heb 2 PIRs die ik aangesloten heb op een raspberry pi. Ik meen dat de PIRs 3 volt afgeven, en die heb ik op ingang van de raspberry PI aangesloten. De raspberry zal per tree een relais aansturen. Is dit voldoende info, of moet ik even de specs van de PIR sensoren opzoeken morgen en met jou delen ?

Outlook voor Androidhttps://aka.ms/ghei36 downloaden


From: Kolk123 notifications@github.com Sent: Thursday, January 3, 2019 2:45:29 PM To: Vinz68/stairsJs Cc: Subscribed Subject: [Vinz68/stairsJs] Vraag (#1)

Ik heb een vraag. aan je naam te zien gok ik dat je nederlands bent. ik heb een trap met 16 ws2812b ledstrips a36 led per tree . mijn doel was om met een arduino mijn leds aan te sturen samen met 2 PIR sensoren. helaas krijg ik dit allemaal niet werkend. zou jij mij kunnen vertellen of jou software mij daarbij kan helpen? en op werkte trigger heb jij de sensoren aangesloten?

Groetjes Roy Kolk

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/Vinz68/stairsJs/issues/1, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMZfBb4t4pYkFOJncHuTs0BIZSaiY5pEks5u_gl5gaJpZM4ZoHS6.

Vinz68 commented 5 years ago

Hallo Roy, weet niet zeker of dit jou het antwoord geeft waar je naar opzoek bent; maar hieronder de spec van de PIR die ik gebruikt heb.

Als je nog vragen hebt hoor ik het wel. Ik update mijn github repository ook gelijk even met de hardware componenten, dan heb ik gelijk alles op 1 plek.

Mocht het allemaal lukken met jou trap stuur dan eens een foto ! , vind ik leuk.

Groeten en succes met je project, Vincent.

[cid:image001.png@01D4A3B3.F75281C0][cid:image001.png@01D4A3B3.F75281C0][cid:image002.png@01D4A3B3.F75281C0][cid:image002.png@01D4A3B3.F75281C0]

  1. Working voltage: DC5V to 20V
  2. static power consumption: 65
  3. output level: high 3.3V, low 0V
  4. delay time: adjustable (0.3 sec ~18 sec)
  5. the embargo time: 0.2 seconds
  6. trigger mode: l not repeatable, h can be repeated, the default value for h
  7. induction range: less than 120 degree cone angle, up to 7 meters
  8. working temperature:- -15~+70 9.PCB dimensions: 32*24mm, screw hole 28mm, screw diameter 2mm, induction of lens dimensions: (diameter): 23mm (default) Features:
  9. automatic: when someone enters the sensing range is input high level, people leaving the induction range is automatically delayed closing high level. Output low level.
  10. light control (optional): module to set aside a location, you can set the photo control, or strong light during the day without induction. Light control is an optional feature, factory photoresistance is not installed. If you want, please purchase the photoresistance installed.
  11. two trigger modes: l not repeatable, h can be repeated. Jumper option defaults to h. A. not repeatable trigger mode: after the sensor output high level, delay time is over, the output will automatically change from high to low level. B. can repeat triggered way: that induction output high level Hou, in delay time paragraph within, if has human in its induction range within activities, its output will has been maintained high level, until people left Hou only delay will high level becomes low level (induction module detection to human of each times activities Hou will automatically extended a delay time paragraph, and to finally once activities of time for delay time of starting points).
  12. induction blackout time (default setting: 0.2 sec): after each induction the induction module output (high level low level), you can immediately set a blackout time, during this time the sensor does not receive any sensor signal. This feature can be achieved (sensor output and blockade times) the interval between work, can be applied to interval detection products; at the same time this function can inhibit various disturbances load in the process of switching.
  13. wide operating voltage range: default voltage DC5V to 20V
  14. power consumption: quiescent current 65, particularly suitable for battery-powered appliances.
  15. high level signal output: can be easily docked with the circuit. [cid:image003.png@01D4A3B3.F75281C0][cid:image004.png@01D4A3B3.F75281C0] 1: power supply 2: high and low level output 3 power negative H: repeatable triggers L: not repeatable triggers CDS: Photo control

Instructions for use:

  1. the induction module powers on for about one minute after initialization, this module can output interval during 0-3 time, one minute after entering standby.
  2. direct sunlight should be avoided as far as possible sources of interference, such as lighting close range module surface of the lens, so as not to introduce interference signals malfunction; using the environment as far as possible to avoid movement of the wind, the wind will cause interference to the sensor.
  3. induction module used double Yuan probe, probe of window for rectangular, double Yuan (a, Yuan b Yuan) is located in more long direction of ends, dang human from left to right or from right to left walked Shi, infrared spectrum reaches double Yuan of time, and distance has poor value, poor value more large, induction more sensitive, dang human from positive to probe or from Shang to Xia or from Xia to above to walked Shi, double Yuan detection does not to infrared spectrum distance of changes, no poor value, therefore induction does not sensitive or does not work ; So when the sensor is installed should probe the dual directions and the directions of human activities up to parallel as far as possible, ensure human passes has dual induction by probes. In order to increase the sensing angle, this module uses the circle lenses, also make probes sensors on all sides, but in both directions up and down left and right side is still strong induction range, sensitivity, must still be installed as far as possible according to the above requirements.

From: Kolk123 notifications@github.com Sent: donderdag 3 januari 2019 14:45 To: Vinz68/stairsJs stairsJs@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [Vinz68/stairsJs] Vraag (#1)

Ik heb een vraag. aan je naam te zien gok ik dat je nederlands bent. ik heb een trap met 16 ws2812b ledstrips a36 led per tree . mijn doel was om met een arduino mijn leds aan te sturen samen met 2 PIR sensoren. helaas krijg ik dit allemaal niet werkend. zou jij mij kunnen vertellen of jou software mij daarbij kan helpen? en op werkte trigger heb jij de sensoren aangesloten?

Groetjes Roy Kolk

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/Vinz68/stairsJs/issues/1, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMZfBb4t4pYkFOJncHuTs0BIZSaiY5pEks5u_gl5gaJpZM4ZoHS6.

Kolk123 commented 5 years ago

Dank je wel voor alle info!! helaas heb ik een digitale strip, en jou verlichting word aansgestuurd op relais. door o.a. jou info, heb ik nu wel de sensoren werkend gekregen. ik krijg alleen niet goed de aantal leds ingesteld. de laatste ledstrip werkt helaas niet. en ook ben ik niet goed in het coderen van een arduino. is nog even uitzoeken dus.

Groetjes roy

Vinz68 commented 5 years ago

Hallo Roy, Ben blij dat je PIR sensoren werken. Jou led-strip, is dat zo’n NeoPixel, waarbij je per led aan/uit kan sturen ?

Ik heb ook een arduino waarmee ik dat ooit eens gedaan heb, en ik kon iets van 80 leds aansturen; en per led de kleur. Daarna had de arduino niet genoeg vermogen om de andere pixels aan te sturen; ik dacht toen dat 2de strip kapot was; maar ik kon 2de strip met 1ste omwisselen en toen kwam ik daarachter.

Hoop dat dit jou nog iets verder helpt (misschien vermogen probleem ?)

Coderen ben ik wel goed in dus als je prog kan sturen wil ik best even kijken of ik iets vreemds in zie. Suc6

Groeten, Vincent. Mail: Vin.van.beek@outlook.com

From: Kolk123 notifications@github.com Sent: zaterdag 5 januari 2019 09:51 To: Vinz68/stairsJs stairsJs@noreply.github.com Cc: Vincent van Beek vin.van.beek@outlook.com; State change state_change@noreply.github.com Subject: Re: [Vinz68/stairsJs] Vraag (#1)

Dank je wel voor alle info!! helaas heb ik een digitale strip, en jou verlichting word aansgestuurd op relais. door o.a. jou info, heb ik nu wel de sensoren werkend gekregen. ik krijg alleen niet goed de aantal leds ingesteld. de laatste ledstrip werkt helaas niet. en ook ben ik niet goed in het coderen van een arduino. is nog even uitzoeken dus.

Groetjes roy

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/Vinz68/stairsJs/issues/1#issuecomment-451638967, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMZfBWft9i5TKBpAzc2Ol8m9UUvdpwW8ks5vAGdzgaJpZM4ZoHS6.

Kolk123 commented 5 years ago

Hoi vincent.

Het is idd een neopixel. Het rare is wel als ik een strandtest doe alles leds netjes werken zoals ze zouden moeten werken. Ik heb op dit moment de leds op 548 gezet. Dan werken 15 strips, en op strip 16 werken er dan 8. Ook de breath modes werkt perfect. Dan doen namelijk alle leds aan de buitenkant enkel op de 161 alleen de rechter kant. Als ik mijn leds nu zet naar 576 dan doet niks het meer. De trap start dan de breath modes en reageerd hij niet meer op de sensoren. Het lijkt dus wel of de software als het ware begrensd is.

Mocht je naar de code willen kijken heel graag. Ik heb 2 soorten geprobeerd. 1 van https://www.instructables.com/id/LED-Stair-Lighting/ En 1 van https://www.instructables.com/id/How-to-bling-up-a-boring-staircase/

De 1e krijg ik werkend tot 548 leds. De 2e maar tot een aantal leds. ( ik geloof 120).

Dit is de code die ik momenteel gebruik.

// Edit by Serge Niko June 2015

include

ifdef AVR

include <avr/power.h>

endif

define PIN 5

// 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(548, 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 = 10; // PIR at the top of the stairs int alarmPinBottom =11; // PIR at the bottom of the stairs int alarmValueTop = HIGH; // Variable to hold the PIR status int alarmValueBottom = HIGH; // 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 = 100; // used in 'breathing' the LED's int breathe = 100; // used in 'breathing' the LED's

void setup() { strip.begin(); strip.setBrightness(20); //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 delay (2000); // it takes the sensor 2 seconds to scan the area around it before it can //detect infrared presence.

}

void loop() {

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(35, blue);
   strip.setPixelColor(36, blue);
   strip.setPixelColor(71, blue);
   strip.setPixelColor(72, blue);
   strip.setPixelColor(107, blue);
   strip.setPixelColor(108, blue);
   strip.setPixelColor(143, blue);
   strip.setPixelColor(144, blue);
   strip.setPixelColor(179, blue);
   strip.setPixelColor(180, blue);
   strip.setPixelColor(215, blue);
   strip.setPixelColor(216, blue);
   strip.setPixelColor(251, blue);
   strip.setPixelColor(252, blue);
   strip.setPixelColor(287, blue);
   strip.setPixelColor(288, blue);
   strip.setPixelColor(323, blue);
   strip.setPixelColor(324, blue);
   strip.setPixelColor(359, blue);
   strip.setPixelColor(360, blue);
   strip.setPixelColor(395, blue);
   strip.setPixelColor(396, blue);
   strip.setPixelColor(431, blue);
   strip.setPixelColor(432, blue);
   strip.setPixelColor(467, blue);
   strip.setPixelColor(468, blue);
   strip.setPixelColor(503, blue);
   strip.setPixelColor(504, blue);
   strip.setPixelColor(539, blue);
   strip.setPixelColor(540, blue);
   strip.setPixelColor(575, 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 (100);           // 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;

}

}

void topdown() { Serial.println ("detected top"); // Helpful debug message colourWipeDown(strip.Color(255, 255, 250), 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, 255, 250), 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 k = 0; k < 16; k++){ int start = strip.numPixels()/16 *k; Serial.println(k);

    for (uint16_t j = start; j < start + 36; j++){
           strip.setPixelColor(j, 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 k = 16; k > 0; k--){ int start = strip.numPixels()/16 *k; Serial.println(k); //start = start-1; for (uint16_t j = start; j > start - 36; j--){ strip.setPixelColor(j-1, c); } strip.show(); delay(wait); }

}

Dank je wel alvast.

Groetjes Roy Kolk

Verzonden vanuit Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 voor Windows 10


Van: Vincent van Beek notifications@github.com Verzonden: Saturday, January 5, 2019 1:41:27 PM Aan: Vinz68/stairsJs CC: Kolk123; Author Onderwerp: Re: [Vinz68/stairsJs] Vraag (#1)

Hallo Roy, Ben blij dat je PIR sensoren werken. Jou led-strip, is dat zo’n NeoPixel, waarbij je per led aan/uit kan sturen ?

Ik heb ook een arduino waarmee ik dat ooit eens gedaan heb, en ik kon iets van 80 leds aansturen; en per led de kleur. Daarna had de arduino niet genoeg vermogen om de andere pixels aan te sturen; ik dacht toen dat 2de strip kapot was; maar ik kon 2de strip met 1ste omwisselen en toen kwam ik daarachter.

Hoop dat dit jou nog iets verder helpt (misschien vermogen probleem ?)

Coderen ben ik wel goed in dus als je prog kan sturen wil ik best even kijken of ik iets vreemds in zie. Suc6

Groeten, Vincent. Mail: Vin.van.beek@outlook.com

From: Kolk123 notifications@github.com Sent: zaterdag 5 januari 2019 09:51 To: Vinz68/stairsJs stairsJs@noreply.github.com Cc: Vincent van Beek vin.van.beek@outlook.com; State change state_change@noreply.github.com Subject: Re: [Vinz68/stairsJs] Vraag (#1)

Dank je wel voor alle info!! helaas heb ik een digitale strip, en jou verlichting word aansgestuurd op relais. door o.a. jou info, heb ik nu wel de sensoren werkend gekregen. ik krijg alleen niet goed de aantal leds ingesteld. de laatste ledstrip werkt helaas niet. en ook ben ik niet goed in het coderen van een arduino. is nog even uitzoeken dus.

Groetjes roy

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/Vinz68/stairsJs/issues/1#issuecomment-451638967, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMZfBWft9i5TKBpAzc2Ol8m9UUvdpwW8ks5vAGdzgaJpZM4ZoHS6.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Vinz68/stairsJs/issues/1#issuecomment-451652411, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AdAlgz5mk6ac2zlgjHNZWzZLkrZvCSpnks5vAJ13gaJpZM4ZoHS6.

Vinz68 commented 5 years ago

Hallo Roy,

Mijn bevindingen, zie onder…. (beetje lang antwoord, maar je moet het er zeker mee aan de praat krijgen !!, zo niet mail dan nog maar eens een keer naar vin.van.beek@outlook.commailto:vin.van.beek@outlook.com. ), en mocht je trap helemaal werken straks dan wil ik wel een foto of filmpje zien ☺ )

Hardware

  1. Jij zegt: “Het rare is wel als ik een strandtest doe alles leds netjes werken zoals ze zouden moeten werken.”
    • OK, alle hardware / ledstrips zijn dus OK neem ik aan.
  2. Ik begrijp, je hebt 16 strips van elk 36 leds , en je kan momenteel max. 548 leds aansturen, dat is best veel. Ik weet niet hoe de voeding/spanning aansturing is, maar mogelijk trekt jou voeding nog net 548 leds, maar 576 niet meer…daar kan je achter komen door:
    • Weet jij de power-consumption per strip of led ? Ik bedoel hiermee, hoeveel mili-ampere (mA) per strip of zo wordt verbruikt ? Hiermee moeten we dan even de totaal aantal benodigde ampere (A) uitrekenen. Bijvoorbeeld:

576 leds X 60 mA = 35 Ampere !!. Als je een hoog ampere nodig hebt (meer dan 10 A bv) dan doe je er goed aan om dat over een paar voedingen te spreiden, bv door er 3 te kopen van bv. 10 A ; (vaak ook prijs gunstiger)

Ik zag in de 1ste link dat daar maar liefst een 5 Volt 60 Ampere voeding was gebruikt; dus kan best dat de strips veel power nodig hebben !.

 *   Voor de LED-strips gebruik jij alleen pin-5 toch ?

Kan haast niet anders, anders zou je maar 125 leds of zo kunnen aansturen want ik meen dat de Arduino een 3.3V regulated output van max. 150 mA heeft, maar hangt af van model van de Arduino ; dit kan je vast opzoeken in de specificatie via Google.

Software Leuk programma/idee heb je met die “breathe” functie erin. Lijkt mij erg cool om te zien werken ; en leuk ook dat je uiteindelijk met kleuren kan werken. Mijn trap is alweer meer dan jaar oud; en toen had je nog niet veel neopixel strips. Wel artikel/bestelnummer gebruik jij voor de ledstrips ? (zelfde als in artikel, de genoemde WS2812B LEDS)? Misschien later mijn trap eens mee updaten ; dit is zoveel cooler !

  1. Als B / voeding goed is, dan nu het programma..

    • Als de “breathe” bezig is, werken de leds op de laatste strip dan goed ? (ik vermoed van wel)
    • In je code zie ik:

                                              i.     Adafruit_NeoPixel strip = Adafruit_NeoPixel(548, PIN, NEO_GRB + NEO_KHZ800);

      Ik neem aan dat dit je dit geprobeerd hebt met 576 zodat je alle pixels kan aansturen. Dit zal nog wel voor de test op 548 staan neem ik aan; maar moet op 576.

                                             ii.     De note over de laatste parameter “NEO_GRB…” zal je ook wel gelezen hebben:

‘…older NeoPixel strips you might need to change the third parameter’

Dit is dus ook een kandidaat om uit te zoeken / welke parameters allemaal mogelijk zijn; mogelijk heb jou strip een andere parameter nodig ; maar ik acht deze opmerking klein, want je kan aansturen…

 *   Ik denk dat je dezelfde functies/libraries gebruikt als ik voor de NeoPixel; dus ik heb je programma eens in mijn arduino geschoten…

Ik moest beetje aanpassen want had alleen 2 neopixel ringen van 60 pixels liggen, dus heb configureerbaar “tredes, ledstrips” en “leds per strip” als variabelen aangemaakt zodat ik kon spelen met 12 tredes/ledstrips van 10 leds each. En…..ik kreeg het programma eigenlijk niet goed aan de praat… Eenmaal als de sensor gezien werd dan bleef bij mij de leds aan, en de breathe functie kwam er dwars doorheen. Dus heb programma beetje ge-her-structureerd (sorry ben 25 jaar SW-Developer geweest), en na de nodige verbouwingen loopt het nu als een tierelier… ☺ .. hoop bij jou ook; probeer het eens, de source staat hier: https://github.com/Vinz68/NeoPixel-Stair

(maar ook onder aan deze mail)

Note er zit een “Tuning part” in, daar kan je snelheden in aanpassen waar nodig. Ik heb een redelijk nieuw/snel arduino board , dus mogelijk moet je de “change” wat hoger zetten, op 5 of 10

 *   Heel veel suc6 ermee, en hoor graag van je hoe je project afloopt !.,

// Copyright Roy en Vincent ☺

include

ifdef AVR

include <avr/power.h>

endif

// Which pin on the Arduino is connected to the NeoPixels?

define PIN 5 // Pin 5 used for the NeoPixels

// How many NeoPixels are attached to the Arduino?

define LEDSPERSTRIP 36 // 36 leds per strip

define LEDSTRIPS 16 // 16 steps

define NUMPIXELS LEDSTRIPS*LEDSPERSTRIP

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

// Set up Variables unsigned long timeOut=0; // timestamp to remember when the PIR was triggered. unsigned long timeLoopStart=0; // timestamp to remember when loop has started. used to determine the end-delay (keeps loop running in same intervals) unsigned long timeTemp=0; // temp. var used in time calculations unsigned long timeDiff=0; // temp. var used in time calculations int downUp = 0; // variable to rememer the direction of travel up or down the stairs int alarmPinTop = 10; // PIR at the top of the stairs int alarmPinBottom =11; // PIR at the bottom of the stairs int alarmValueTop = HIGH; // Variable to hold the PIR status int alarmValueBottom = HIGH; // 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

//------------------------------------------------------------------------- // Tuning part for the Breathe effect en turn-on and turn-off speed //------------------------------------------------------------------------- int change = 2; // used in 'breathing' the LED's , make value smalle to make it smoother, or higher to make it faster int breathe = 25; // used in 'breathing' the LED's, start at range 5 int turnOnSpeed=30; // speed to turn on next led-strip, in msec between next strip int turnOffSpeed=100; // speed to turn on next led-strip, in msec between next strip int keepLedsOnTime=18000; // keep leds on for at least .. msec. int keepLedsOffTime=1500; // keep leds off for at least .. msec.

void setup() {

strip.begin(); // This initializes the NeoPixel library.

strip.setBrightness(35); // Adjust brightness here clearStrip(); // Initialize all pixels to 'off', and do strip.show()

//Serial.begin (9600); // only required for debugging

// Configure the used digital input & output 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

delay (2000); // it takes the sensor 2 seconds to scan the area around it before it can detect infrared presence. }

void loop() {

// register the current time (in msec, for later use to optimize the execution loop) timeLoopStart=millis();

alarmValueTop = digitalRead(alarmPinTop); // Constantly poll the PIR at the top of the stairs if ( (alarmValueTop == HIGH) && (downUp == 0) ) { // the 2nd term indicates that there is currently no activity (up or down) timeOut=millis(); // Timestamp when the PIR is triggered. The LED cycle wil then start. downUp = 1; colourWipeDown(strip.Color(255, 255, 250), turnOnSpeed ); // Warm White,led-light from top to down }

alarmValueBottom = digitalRead(alarmPinBottom); // Constantly poll the PIR at the bottom of the stairs if ( (alarmValueBottom == HIGH) && (downUp == 0)) { // the 2nd term indicates that there is currently no activity (up or down) timeOut=millis(); // Timestamp when the PIR is triggered. The LED cycle wil then start. downUp = 2; colourWipeUp(strip.Color(255, 255, 250), turnOnSpeed); // Warm White,led-light from bottom to top }

if ( (downUp!=0) && (timeOut+keepLedsOnTime < millis()) ) { //switch off LED's in the direction of travel. if (downUp == 1) { downUp = 3; // mode = turn off leds from top to down colourWipeDown(strip.Color(0, 0, 0), turnOffSpeed); // Off downUp=5; // Stairs are just turned off } if (downUp == 2) { downUp = 4; // mode = turn off leds from bottom to top colourWipeUp(strip.Color(0, 0, 0), turnOffSpeed); // Off downUp=5; // Stairs are just turned off } }

if (downUp==0) // Currently no activity on the stairs ? (in idle mode, not turned (or turning) on or off ?) handleBreathe(); // Then Enable the cool "breathe effect" of the led strip lights else if (downUp==5) { // eventually the stairs led lights will be turned of again (mode=5) delay(keepLedsOffTime); // allow small delay/pause and then activate the stairs again with the breathe and motion detection function downUp=0; // set to 0 to allow breathe/motion detection (-1 for debugging one run) }

}

void handleBreathe() {

// blue value changes breathe = breathe + change;

// breathe the LED from 20 = off to 100 = fairly bright, change values if needed if ( (breathe >= 100 || breathe <= 20) ) {

change = -change;         // toggle the value to increase/decrease the breathe value

timeTemp = millis();
timeDiff = timeTemp - timeLoopStart;

// Program execution was shorter than 150 msec ? Then delay up to 150 msec, for a smooth breathe
// NOTE: shorten the 150-numbers to a lower (same) value when breath is to slow..
if (timeDiff < 150) {
  delay(150-timeDiff);  // Pause at beginning and end of each breath
}
else {
  // Program execution was longer than 150 msec, so no delay needed
}

} else {

// Set outside leds to breathe-value
strip.setPixelColor(0, strip.Color(0,0,breathe));
strip.setPixelColor(35, strip.Color(0,0,breathe));
strip.setPixelColor(36, strip.Color(0,0,breathe));
strip.setPixelColor(71, strip.Color(0,0,breathe));
strip.setPixelColor(72, strip.Color(0,0,breathe));
strip.setPixelColor(107, strip.Color(0,0,breathe));
strip.setPixelColor(108, strip.Color(0,0,breathe));
strip.setPixelColor(143, strip.Color(0,0,breathe));
strip.setPixelColor(144, strip.Color(0,0,breathe));
strip.setPixelColor(179, strip.Color(0,0,breathe));
strip.setPixelColor(180, strip.Color(0,0,breathe));
strip.setPixelColor(215, strip.Color(0,0,breathe));
strip.setPixelColor(216, strip.Color(0,0,breathe));
strip.setPixelColor(251, strip.Color(0,0,breathe));
strip.setPixelColor(252, strip.Color(0,0,breathe));
strip.setPixelColor(287, strip.Color(0,0,breathe));
strip.setPixelColor(288, strip.Color(0,0,breathe));
strip.setPixelColor(323, strip.Color(0,0,breathe));
strip.setPixelColor(324, strip.Color(0,0,breathe));
strip.setPixelColor(359, strip.Color(0,0,breathe));
strip.setPixelColor(360, strip.Color(0,0,breathe));
strip.setPixelColor(395, strip.Color(0,0,breathe));
strip.setPixelColor(396, strip.Color(0,0,breathe));
strip.setPixelColor(431, strip.Color(0,0,breathe));
strip.setPixelColor(432, strip.Color(0,0,breathe));
strip.setPixelColor(467, strip.Color(0,0,breathe));
strip.setPixelColor(468, strip.Color(0,0,breathe));
strip.setPixelColor(503, strip.Color(0,0,breathe));
strip.setPixelColor(504, strip.Color(0,0,breathe));
strip.setPixelColor(539, strip.Color(0,0,breathe));
strip.setPixelColor(540, strip.Color(0,0,breathe));
strip.setPixelColor(575, strip.Color(0,0,breathe));

strip.show();

timeTemp = millis();
timeDiff = timeTemp - timeLoopStart;

// Program execution (timeDiff) was shorter than 25 msec ? Then delay up to 25 msec, for a smooth breathe
// NOTE: shorten the 25-numbers to a lower (same) value when breath is to slow..
if (timeDiff < 25) {
  delay(25-timeDiff);
}
else {
  // Program execution was longer than 25 msec, no delay needed
}

} }

// Fade light each step strip void colourWipeDown(uint32_t c, uint16_t wait) {

for (uint16_t k = 0; k < LEDSTRIPS; k++){

int start = (NUMPIXELS/LEDSTRIPS) *k;
Serial.println(k);

for (uint16_t j = start; j < start + LEDSPERSTRIP; j++){
  strip.setPixelColor(j, c);
}
strip.show();
delay(wait);

} }

// Fade light each step strip void colourWipeUp(uint32_t c, uint16_t wait) {

for (uint16_t k = LEDSTRIPS; k > 0; k--){

int start = NUMPIXELS/LEDSTRIPS *k;
//Serial.println(k);

int x = start;
do
{
  strip.setPixelColor(x-1, c);
  x--;
} while (x > start - LEDSPERSTRIP);

strip.show();
delay(wait);

} }

void clearStrip(){ // All pixels off for (int l=0; l<NUMPIXELS; l++){ strip.setPixelColor(l, strip.Color(0,0,0)); }

strip.show(); // This sends the updated pixel's to the hardware. }

From: Kolk123 notifications@github.com Sent: zaterdag 5 januari 2019 13:50 To: Vinz68/stairsJs stairsJs@noreply.github.com Cc: Vincent van Beek vin.van.beek@outlook.com; State change state_change@noreply.github.com Subject: Re: [Vinz68/stairsJs] Vraag (#1)

Hoi vincent.

Het is idd een neopixel. Het rare is wel als ik een strandtest doe alles leds netjes werken zoals ze zouden moeten werken. Ik heb op dit moment de leds op 548 gezet. Dan werken 15 strips, en op strip 16 werken er dan 8. Ook de breath modes werkt perfect. Dan doen namelijk alle leds aan de buitenkant enkel op de 161 alleen de rechter kant. Als ik mijn leds nu zet naar 576 dan doet niks het meer. De trap start dan de breath modes en reageerd hij niet meer op de sensoren. Het lijkt dus wel of de software als het ware begrensd is.

Mocht je naar de code willen kijken heel graag. Ik heb 2 soorten geprobeerd. 1 van https://www.instructables.com/id/LED-Stair-Lighting/ En 1 van https://www.instructables.com/id/How-to-bling-up-a-boring-staircase/

De 1e krijg ik werkend tot 548 leds. De 2e maar tot een aantal leds. ( ik geloof 120).

Dit is de code die ik momenteel gebruik.

// Edit by Serge Niko June 2015

include

ifdef AVR

include <avr/power.h>

endif

define PIN 5

// 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(548, 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 = 10; // PIR at the top of the stairs int alarmPinBottom =11; // PIR at the bottom of the stairs int alarmValueTop = HIGH; // Variable to hold the PIR status int alarmValueBottom = HIGH; // 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 = 100; // used in 'breathing' the LED's int breathe = 100; // used in 'breathing' the LED's

void setup() { strip.begin(); strip.setBrightness(20); //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 delay (2000); // it takes the sensor 2 seconds to scan the area around it before it can //detect infrared presence.

}

void loop() {

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(35, blue); strip.setPixelColor(36, blue); strip.setPixelColor(71, blue); strip.setPixelColor(72, blue); strip.setPixelColor(107, blue); strip.setPixelColor(108, blue); strip.setPixelColor(143, blue); strip.setPixelColor(144, blue); strip.setPixelColor(179, blue); strip.setPixelColor(180, blue); strip.setPixelColor(215, blue); strip.setPixelColor(216, blue); strip.setPixelColor(251, blue); strip.setPixelColor(252, blue); strip.setPixelColor(287, blue); strip.setPixelColor(288, blue); strip.setPixelColor(323, blue); strip.setPixelColor(324, blue); strip.setPixelColor(359, blue); strip.setPixelColor(360, blue); strip.setPixelColor(395, blue); strip.setPixelColor(396, blue); strip.setPixelColor(431, blue); strip.setPixelColor(432, blue); strip.setPixelColor(467, blue); strip.setPixelColor(468, blue); strip.setPixelColor(503, blue); strip.setPixelColor(504, blue); strip.setPixelColor(539, blue); strip.setPixelColor(540, blue); strip.setPixelColor(575, 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 (100); // 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;

}

}

void topdown() { Serial.println ("detected top"); // Helpful debug message colourWipeDown(strip.Color(255, 255, 250), 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, 255, 250), 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 k = 0; k < 16; k++){ int start = strip.numPixels()/16 *k; Serial.println(k);

for (uint16_t j = start; j < start + 36; j++){ strip.setPixelColor(j, 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 k = 16; k > 0; k--){ int start = strip.numPixels()/16 *k; Serial.println(k); //start = start-1; for (uint16_t j = start; j > start - 36; j--){ strip.setPixelColor(j-1, c); } strip.show(); delay(wait); }

}

Dank je wel alvast.

Groetjes Roy Kolk

Verzonden vanuit Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 voor Windows 10


Van: Vincent van Beek notifications@github.com<mailto:notifications@github.com> Verzonden: Saturday, January 5, 2019 1:41:27 PM Aan: Vinz68/stairsJs CC: Kolk123; Author Onderwerp: Re: [Vinz68/stairsJs] Vraag (#1)

Hallo Roy, Ben blij dat je PIR sensoren werken. Jou led-strip, is dat zo’n NeoPixel, waarbij je per led aan/uit kan sturen ?

Ik heb ook een arduino waarmee ik dat ooit eens gedaan heb, en ik kon iets van 80 leds aansturen; en per led de kleur. Daarna had de arduino niet genoeg vermogen om de andere pixels aan te sturen; ik dacht toen dat 2de strip kapot was; maar ik kon 2de strip met 1ste omwisselen en toen kwam ik daarachter.

Hoop dat dit jou nog iets verder helpt (misschien vermogen probleem ?)

Coderen ben ik wel goed in dus als je prog kan sturen wil ik best even kijken of ik iets vreemds in zie. Suc6

Groeten, Vincent. Mail: Vin.van.beek@outlook.commailto:Vin.van.beek@outlook.com

From: Kolk123 notifications@github.com<mailto:notifications@github.com> Sent: zaterdag 5 januari 2019 09:51 To: Vinz68/stairsJs stairsJs@noreply.github.com<mailto:stairsJs@noreply.github.com> Cc: Vincent van Beek vin.van.beek@outlook.com<mailto:vin.van.beek@outlook.com>; State change state_change@noreply.github.com<mailto:state_change@noreply.github.com> Subject: Re: [Vinz68/stairsJs] Vraag (#1)

Dank je wel voor alle info!! helaas heb ik een digitale strip, en jou verlichting word aansgestuurd op relais. door o.a. jou info, heb ik nu wel de sensoren werkend gekregen. ik krijg alleen niet goed de aantal leds ingesteld. de laatste ledstrip werkt helaas niet. en ook ben ik niet goed in het coderen van een arduino. is nog even uitzoeken dus.

Groetjes roy

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/Vinz68/stairsJs/issues/1#issuecomment-451638967, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMZfBWft9i5TKBpAzc2Ol8m9UUvdpwW8ks5vAGdzgaJpZM4ZoHS6.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Vinz68/stairsJs/issues/1#issuecomment-451652411, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AdAlgz5mk6ac2zlgjHNZWzZLkrZvCSpnks5vAJ13gaJpZM4ZoHS6.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/Vinz68/stairsJs/issues/1#issuecomment-451652918, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMZfBaCJ8SFc8SAvidfpoZwsdtK3dT_sks5vAJ9kgaJpZM4ZoHS6.