Arduino trap verlichting probleem

Arduino specifieke Software
Berichten: 3
Geregistreerd: 05 Jan 2019, 02:01

Arduino trap verlichting probleem

Berichtdoor kolk123 » 05 Jan 2019, 02:12

Hoi Allemaal.

Ik ben helemaal nieuw in de arduino wereld.

Ik ben begonnen met een trap project. ik ben in het bezit van een arduino uno rev3.
ik heb 10 meter ledstrip wb2812B. ik deze deze op 16 treedes geplaatst.
deze word gevoed elke 36 leds door een 5v 40ah voeding.

nu heb ik een probleem. ik gebruik de code van deze website. https://www.instructables.com/id/LED-Stair-Lighting/

ik krijg deze helaas niet aan de praat. ik heb 576 led op 16 tredes dus 36leds per tree. de persoon van de tutorial 525 op 15 tredes dus 35 per tree.
ik heb geprobeerd de code onderin aan te passen naar de juiste aantallen. enkel als ik meer dan 548 led opgeef dus mijn 576 doet niks het meer.
als ik 548 aangeef brand de laatste strip (16) enkel 8 leds.
kan iemand mij a.u.b. helpen. ik ben al 20 uur aan het prutsen zonder resultaat. dit is de code die ik nu gebruik.


Code: Alles selecteren
// Edit by Serge Niko June 2015

#include <Adafruit_NeoPixel.h>


#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(575, 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 = 1;            // used in 'breathing' the LED's
 int breathe = 0;           // used in 'breathing' the LED's
 

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

 


Advertisement

Berichten: 3
Geregistreerd: 05 Jan 2019, 02:01

Re: Arduino trap verlichting probleem

Berichtdoor kolk123 » 08 Jan 2019, 19:59

Probleem is opgelost.

Waar niemand het antwoord op had, heb ik een arduino mega aangeschaft ipv een uno.

Deze werkt als een trein. het was dus toch de kracht van de arduino die het liet afweten!
Voor mijn volgers dus gebruik een arduino mega 2560!

Berichten: 4064
Geregistreerd: 16 Okt 2013, 14:31
Woonplaats: s hertogenbosch

Re: Arduino trap verlichting probleem

Berichtdoor shooter » 08 Jan 2019, 21:36

Dat is toch de beperkte hoeveelheid geheugen in een UNO. Ik zou overigens wel de treden en leds per trede in een variabele zetten, dus 16 en 35 bovenin een variabele, dat is slimmer.
paul deelen
shooter@home.nl

Terug naar Arduino software

Wie is er online?

Gebruikers in dit forum: Google [Bot], uejilego en 18 gasten