Adafruit_NeoPixel seens to be limited to 110 leds in the string

Status
Not open for further replies.

philip.porhammer

Well-known member
Adafruit_NeoPixel seems to be limited to 110 LEDs in the string.
the clock is 60 LEDS in the outer ring and 48 in the inner ring and 12 markers. is there a quick mod to this to fix this?
my setup:
Code:
#include <SPI.h>
#include <SparkFunDS3234RTC.h>
#define DS13074_CS_PIN 10 // DeadOn RTC Chip-select pin
#include <Adafruit_NeoPixel.h>
#define PIN 1 // led serial
#define NUMPIXELS 120
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_RGB + NEO_KHZ800);




 /*--------------------------------------------------------------------
  This file is part of the Adafruit NeoPixel library.

  NeoPixel is free software: you can redistribute it and/or modify
  it under the terms of the GNU Lesser General Public License as
  published by the Free Software Foundation, either version 3 of
  the License, or (at your option) any later version.

  NeoPixel is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with NeoPixel.  If not, see
  <http://www.gnu.org/licenses/>.
  --------------------------------------------------------------------*/

#ifndef ADAFRUIT_NEOPIXEL_H
#define ADAFRUIT_NEOPIXEL_H

#if (ARDUINO >= 100)
 #include <Arduino.h>
#else
 #include <WProgram.h>
 #include <pins_arduino.h>
#endif

// The order of primary colors in the NeoPixel data stream can vary
// among device types, manufacturers and even different revisions of
// the same item.  The third parameter to the Adafruit_NeoPixel
// constructor encodes the per-pixel byte offsets of the red, green
// and blue primaries (plus white, if present) in the data stream --
// the following #defines provide an easier-to-use named version for
// each permutation.  e.g. NEO_GRB indicates a NeoPixel-compatible
// device expecting three bytes per pixel, with the first byte
// containing the green value, second containing red and third
// containing blue.  The in-memory representation of a chain of
// NeoPixels is the same as the data-stream order; no re-ordering of
// bytes is required when issuing data to the chain.

// Bits 5,4 of this value are the offset (0-3) from the first byte of
// a pixel to the location of the red color byte.  Bits 3,2 are the
// green offset and 1,0 are the blue offset.  If it is an RGBW-type
// device (supporting a white primary in addition to R,G,B), bits 7,6
// are the offset to the white byte...otherwise, bits 7,6 are set to
// the same value as 5,4 (red) to indicate an RGB (not RGBW) device.
// i.e. binary representation:
// 0bWWRRGGBB for RGBW devices
// 0bRRRRGGBB for RGB

// RGB NeoPixel permutations; white and red offsets are always same
// Offset:         W          R          G          B
#define NEO_RGB  ((0 << 6) | (0 << 4) | (1 << 2) | (2))
#define NEO_RBG  ((0 << 6) | (0 << 4) | (2 << 2) | (1))
#define NEO_GRB  ((1 << 6) | (1 << 4) | (0 << 2) | (2))
#define NEO_GBR  ((2 << 6) | (2 << 4) | (0 << 2) | (1))
#define NEO_BRG  ((1 << 6) | (1 << 4) | (2 << 2) | (0))
#define NEO_BGR  ((2 << 6) | (2 << 4) | (1 << 2) | (0))

// RGBW NeoPixel permutations; all 4 offsets are distinct
// Offset:         W          R          G          B
#define NEO_WRGB ((0 << 6) | (1 << 4) | (2 << 2) | (3))
#define NEO_WRBG ((0 << 6) | (1 << 4) | (3 << 2) | (2))
#define NEO_WGRB ((0 << 6) | (2 << 4) | (1 << 2) | (3))
#define NEO_WGBR ((0 << 6) | (3 << 4) | (1 << 2) | (2))
#define NEO_WBRG ((0 << 6) | (2 << 4) | (3 << 2) | (1))
#define NEO_WBGR ((0 << 6) | (3 << 4) | (2 << 2) | (1))

#define NEO_RWGB ((1 << 6) | (0 << 4) | (2 << 2) | (3))
#define NEO_RWBG ((1 << 6) | (0 << 4) | (3 << 2) | (2))
#define NEO_RGWB ((2 << 6) | (0 << 4) | (1 << 2) | (3))
#define NEO_RGBW ((3 << 6) | (0 << 4) | (1 << 2) | (2))
#define NEO_RBWG ((2 << 6) | (0 << 4) | (3 << 2) | (1))
#define NEO_RBGW ((3 << 6) | (0 << 4) | (2 << 2) | (1))

#define NEO_GWRB ((1 << 6) | (2 << 4) | (0 << 2) | (3))
#define NEO_GWBR ((1 << 6) | (3 << 4) | (0 << 2) | (2))
#define NEO_GRWB ((2 << 6) | (1 << 4) | (0 << 2) | (3))
#define NEO_GRBW ((3 << 6) | (1 << 4) | (0 << 2) | (2))
#define NEO_GBWR ((2 << 6) | (3 << 4) | (0 << 2) | (1))
#define NEO_GBRW ((3 << 6) | (2 << 4) | (0 << 2) | (1))

#define NEO_BWRG ((1 << 6) | (2 << 4) | (3 << 2) | (0))
#define NEO_BWGR ((1 << 6) | (3 << 4) | (2 << 2) | (0))
#define NEO_BRWG ((2 << 6) | (1 << 4) | (3 << 2) | (0))
#define NEO_BRGW ((3 << 6) | (1 << 4) | (2 << 2) | (0))
#define NEO_BGWR ((2 << 6) | (3 << 4) | (1 << 2) | (0))
#define NEO_BGRW ((3 << 6) | (2 << 4) | (1 << 2) | (0))

// Add NEO_KHZ400 to the color order value to indicate a 400 KHz
// device.  All but the earliest v1 NeoPixels expect an 800 KHz data
// stream, this is the default if unspecified.  Because flash space
// is very limited on ATtiny devices (e.g. Trinket, Gemma), v1
// NeoPixels aren't handled by default on those chips, though it can
// be enabled by removing the ifndef/endif below -- but code will be
// bigger.  Conversely, can disable the NEO_KHZ400 line on other MCUs
// to remove v1 support and save a little space.

#define NEO_KHZ800 0x0000 // 800 KHz datastream
#ifndef __AVR_ATtiny85__
#define NEO_KHZ400 0x0100 // 400 KHz datastream
#endif

// If 400 KHz support is enabled, the third parameter to the constructor
// requires a 16-bit value (in order to select 400 vs 800 KHz speed).
// If only 800 KHz is enabled (as is default on ATtiny), an 8-bit value
// is sufficient to encode pixel color order, saving some space.

#ifdef NEO_KHZ400
typedef uint16_t neoPixelType;
#else
typedef uint8_t  neoPixelType;
#endif

class Adafruit_NeoPixel {

 public:

  // Constructor: number of LEDs, pin number, LED type
  Adafruit_NeoPixel(uint16_t n, uint8_t p=6, neoPixelType t=NEO_GRB + NEO_KHZ800);
  Adafruit_NeoPixel(void);
  ~Adafruit_NeoPixel();

  void
    begin(void),
    show(void),
    setPin(uint8_t p),
    setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b),
    setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w),
    setPixelColor(uint16_t n, uint32_t c),
    setBrightness(uint8_t),
    clear(),
    updateLength(uint16_t n),
    updateType(neoPixelType t);
  uint8_t
   *getPixels(void) const,
    getBrightness(void) const;
  uint16_t
    numPixels(void) const;
  static uint32_t
    Color(uint8_t r, uint8_t g, uint8_t b),
    Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w);
  uint32_t
    getPixelColor(uint16_t n) const;
  inline bool
    canShow(void) { return (micros() - endTime) >= 50L; }

 private:

  boolean
#ifdef NEO_KHZ400  // If 400 KHz NeoPixel support enabled...
    is800KHz,      // ...true if 800 KHz pixels
#endif
    begun;         // true if begin() previously called
  uint16_t
    numLEDs,       // Number of RGB LEDs in strip
    numBytes;      // Size of 'pixels' buffer below (3 or 4 bytes/pixel)
  int8_t
    pin;           // Output pin number (-1 if not yet set)
  uint8_t
    brightness,
   *pixels,        // Holds LED color values (3 or 4 bytes each)
    rOffset,       // Index of red byte within each 3- or 4-byte pixel
    gOffset,       // Index of green byte
    bOffset,       // Index of blue byte
    wOffset;       // Index of white byte (same as rOffset if no white)
  uint32_t
    endTime;       // Latch timing reference
#ifdef __AVR__
  volatile uint8_t
    *port;         // Output PORT register
  uint8_t
    pinMask;       // Output PORT bitmask
#endif

};

#endif // ADAFRUIT_NEOPIXEL_H
 
Last edited by a moderator:
It probably depends on what Teensy you have. The Teensy LC does not have all that much memory (8K of SDRAM), so it is possible that allocating 120 LEDs is just too much memory. The Teensy 3.2 has 64K of SDRAM. I think 8K should be enough for just 120 LEDs. If you have a Teensy 2.0 or 2.0++, then it may be likely that you could be running out of memory.

A more probable answer is the LEDs probably consume too much power for the Teensy, and it shuts down when the power is too great. One solution is to change the maximum brightness for your lights so that they don't use as much power. Another solution is provide an independent power supply for the lights.

You might want to provide the full program you use, rather than just the snipet at the beginning. This way somebody interested can clip the source and try to run it. You don't have to include Adafruit_Neopixels.h unless you have changed it. Please also show how you have wired up the neopixels and how you power the Teensy. Finally, mention what Teensy you are using, and what the failure symptoms are (does it fail immediately, or does it work for a bit and then fail)?

Finally when you post code, use the '#' toolbar button to wrap the code with CODE and /CODE markers so that it is properly indented.
 
I am using a Teency 3.2
the outer ring is minutes, seconds with the 5 , 10 , 15.... minutes a markers a blue point.
the inner ring is hours, sun position , moon position, hours of daylight bright yellow, hours on night blue.
I would put a picture but I can't figure out how to get a good pic of NeoPixels.
and it dims at might, I use a 4Amp PS.
Code:
/* inputs:
reset seconds button
inc minutes button
inc hours button
daylight savings  switch
inc select day
inc select month
inc select moon phase
inc day/month/ moon phase pot
*/

#include <SPI.h>
#include <SparkFunDS3234RTC.h>
#define DS13074_CS_PIN 10 // DeadOn RTC Chip-select pin
#include <Adafruit_NeoPixel.h>
#define PIN 1 // led serial
#define NUMPIXELS 111
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_RGB + NEO_KHZ800);
//int delayval = 100; // delay for half a second
int secondVal=0;
int minVal=0;
int hourVal=1;
int hourVal_24=1;
int hourDisp=1;
int temphour=1;
int SunPosition=0;
int DayLightSavings=0;     //************DayLightSavings=0; normal
int MoonPosition=2;
int HiLow=1;
int Rr=0;
int Gg=0;
int Bb=0; 
static int8_t lastSecond = -1;
int MoonArray[]={0,0,31,60,91,121,152,182,213,244,274,305,335};// moon phase varables
int DayOfYear=1;// moon phase varables
int days=1;// moon phase varables


int moondays;
 int MoonOffset=-10
 ;
int WeekOfYear;
int longetude=8;     //**************longetude   (x+1)  (90/15) is 6 degrees of resolution
int HoursInDay;
int DayLength[]={
12,12,11,11,11,10,10,9,8,7,6,3,0,0,0,
12,12,11,11,11,10,10,9,9,8,6,4,0,0,0,
12,12,11,11,11,10,10,9,9,8,7,4,0,0,0,
12,12,12,11,11,11,10,10,9,8,7,5,0,0,0,
12,12,12,11,11,11,10,10,9,9,8,6,2,0,0,
12,12,12,11,11,11,10,10,10,9,8,7,4,0,0,
12,12,12,11,11,11,11,10,10,9,9,8,6,0,0,
12,12,12,12,11,11,11,11,10,10,9,9,7,3,0,
12,12,12,12,12,11,11,11,11,10,10,9,8,6,0,
12,12,12,12,12,12,11,11,11,11,11,10,10,8,1,
12,12,12,12,12,12,12,12,12,11,11,11,11,10,8,
12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,
12,12,12,12,12,12,12,12,12,12,13,13,13,13,15,
12,12,12,12,12,12,13,13,13,13,13,14,14,15,20,
12,12,12,12,13,13,13,13,13,13,14,14,15,17,24,
12,12,12,13,13,13,13,13,14,14,14,15,17,20,24,
12,12,12,13,13,13,13,14,14,14,15,16,18,24,24,
12,12,13,13,13,13,14,14,14,15,16,17,19,24,24,
12,12,13,13,13,13,14,14,15,15,16,18,22,24,24,
12,12,13,13,13,14,14,14,15,16,17,19,24,24,24,
12,12,13,13,13,14,14,15,15,16,17,20,24,24,24,
12,12,13,13,13,14,14,15,16,17,18,21,24,24,24,
12,12,13,13,14,14,14,15,16,17,18,22,24,24,24,
12,12,13,13,14,14,15,15,16,17,19,23,24,24,24,
12,12,13,13,14,14,15,15,16,17,19,24,24,24,24,
12,12,13,13,14,14,15,15,16,17,19,24,24,24,24,
12,12,13,13,14,14,15,15,16,17,19,24,24,24,24,
12,12,13,13,14,14,15,15,16,17,18,22,24,24,24,
12,12,13,13,13,14,14,15,16,17,18,21,24,24,24,
12,12,13,13,13,14,14,15,15,16,18,20,24,24,24,
12,12,13,13,13,14,14,15,15,16,17,19,24,24,24,
12,12,13,13,13,14,14,14,15,16,17,18,24,24,24,
12,12,13,13,13,13,14,14,15,15,16,17,20,24,24,
12,12,12,13,13,13,13,14,14,15,15,17,19,24,24,
12,12,12,13,13,13,13,13,14,14,15,16,17,22,24,
12,12,12,12,13,13,13,13,13,14,14,15,16,18,24,
12,12,12,12,12,13,13,13,13,13,14,14,15,16,24,
12,12,12,12,12,12,12,13,13,13,13,13,14,14,17,
12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,
12,12,12,12,12,12,12,12,12,12,12,12,11,11,10,
12,12,12,12,12,12,12,12,11,11,11,11,10,9,6,
12,12,12,12,12,12,11,11,11,11,10,10,9,7,0,
12,12,12,12,11,11,11,11,11,10,10,9,8,5,0,
12,12,12,12,11,11,11,11,10,10,9,8,7,0,0,
12,12,12,11,11,11,11,10,10,9,9,7,5,0,0,
12,12,12,11,11,11,10,10,10,9,8,7,3,0,0,
12,12,12,11,11,11,10,10,9,8,7,6,0,0,0,
12,12,12,11,11,10,10,10,9,8,7,5,0,0,0,
12,12,11,11,11,10,10,9,9,8,6,4,0,0,0,
12,12,11,11,11,10,10,9,9,8,6,3,0,0,0,
12,12,11,11,11,10,10,9,8,7,6,3,0,0,0,
12,12,11,11,11,10,10,9,8,7,6,3,0,0,0,
12,12,11,11,11,10,10,9,8,7,6,3,0,0,0,
12,12,12,11,11,11,11,10,10,9,9,7,5,0,0,
12,12,12,11,11,11,10,10,10,9,8,7,3,0,0,
12,12,12,11,11,11,10,10,9,8,7,6,0,0,0,
12,12,12,11,11,10,10,10,9,8,7,5,0,0,0,
12,12,11,11,11,10,10,9,9,8,6,4,0,0,0,
12,12,11,11,11,10,10,9,9,8,6,3,0,0,0,
12,12,11,11,11,10,10,9,8,7,6,3,0,0,0,
12,12,11,11,11,10,10,9,8,7,6,3,0,0,0,
12,12,11,11,11,10,10,9,8,7,6,3,0,0,0,
};





void setup() 
{
  Serial.begin(9600);
  rtc.begin(DS13074_CS_PIN); // Call rtc.begin([cs]) to initialize the library //rtc.set12Hour(); // Use rtc.set12Hour to set to 12-hour mode
  delay(10);
//rtc.autoTime(); //                         **************** set to PC time!!!!!!!!!!!!!!!!! *********************************************************************
  delay (10);
  rtc.update();
  delay (1);
  pixels.begin(); // This initializes the NeoPixel library.
 // SelfTest();
}

void loop() 
{HoldASec();
   for(int i=0;i<111;i++)
       {
    // if ( hourVal_24==22){HiLow=0;}// tunr down at night
    // if (hourVal_24==6){HiLow=1;}
      
         //  DAY TIME*********************************************
          Rr=0;Gg=10;Bb=0;// reset colors 
         if (i==5||i==10||i==15 ||i==20||i==25 ||i==30||i==35||i==40||i==45 ||i==50||i==55 ||i==0){ Bb=200;} 
              if(i>62&&i<107){Rr=0;Gg=0;Bb=30;}    // nite arch
              if(i>59&&i<(73+HoursInDay)){Rr=9;Gg=15;Bb=0;} //sun arch
              if(i>(95-HoursInDay)&&i<109){Rr=9;Gg=15;Bb=0;}//Sun arch           
          
           if (i==secondVal){Gg=155;}          // second hand
           if( i==minVal){Rr=155;}             //minute hand
           if( i==hourDisp){Rr=155;Bb=0;}           //hour hand
           if (i==SunPosition){Rr=155;Gg=155;}  // sun hand MoonPosition
           if (i==MoonPosition){Rr=0;Gg=155;Bb=155;}  // sun hand MoonPosition
           
         
       
        if (i==108){Rr=0;Gg=20;Bb=0;}
         if (i==109){Rr=0;Gg=00;Bb=20;}
            pixels.setPixelColor(i, pixels.Color(Rr,Gg,Bb)); // Moderately bright green color.
       }
             pixels.show();
}





void HoldASec()
{   rtc.update();
    lastSecond = rtc.second();
       while (rtc.second() == lastSecond) // If the second has changed
             {delay(10); rtc.update(); } 
  
  secondVal=rtc.second();//GET NEW TIME
  minVal=rtc.minute();
  hourVal_24=rtc.hour();//(rtc.hour()( temphour)
  
  hourDisp=hourVal_24;

  
  if(hourDisp>12){hourDisp=hourDisp-12;}//GET THE HOUR HAND IN THE CORRECT PLACE
  hourDisp=hourDisp*4+60;
    if( minVal>7){hourDisp=hourDisp+1;}// BUMP IN 15 MIN INCREMENTS
    if( minVal>22){hourDisp=hourDisp+1;}
    if( minVal>37){hourDisp=hourDisp+1;}
    if( minVal>52){hourDisp=hourDisp+1;}
  if(hourDisp>107){hourDisp=hourDisp-48;}
//******************************************************************sun position

    SunPosition=((hourVal_24*2)+60+24-(DayLightSavings*2));//hourVal_24*2
        if(minVal>30){SunPosition++;}
      
         if(SunPosition>107){SunPosition=SunPosition-48;}
       if(SunPosition==hourDisp){SunPosition++;}
         if(SunPosition>107){SunPosition=SunPosition-48;}

//***********************************************************************moon position  rtc.month()rtc.date()


DayOfYear=rtc.date()+ MoonArray[rtc.month()]; // Serial.println(DayOfYear);   
 // DayOfYear++;

 
 
   moondays=DayOfYear;                                   
  while(moondays>59)                                     
  {moondays=moondays-59;}
  moondays=moondays*1.62711;
  
if (DayOfYear>356){DayOfYear =1;}
  Serial.print("DayOfYear  ");   Serial.println(DayOfYear);
   Serial.print("Moonday ");   Serial.println(moondays); 
  
  MoonPosition=SunPosition-moondays + MoonOffset;
 
     
   while (MoonPosition<48){MoonPosition=MoonPosition+48;}// keep it in the display
      if(MoonPosition>107){MoonPosition=MoonPosition-48;}
       if(MoonPosition==hourDisp){MoonPosition++;}
            if(MoonPosition>107){MoonPosition=MoonPosition-48;}
       if(MoonPosition==SunPosition){MoonPosition++;}  
        if(MoonPosition>107){MoonPosition=MoonPosition-48;}


WeekOfYear=DayOfYear/7;// DayOfYear
WeekOfYear=WeekOfYear*15+longetude;
HoursInDay=DayLength[WeekOfYear];
HoursInDay=HoursInDay-12;// value relative to 12 hour day.
Serial.println(HoursInDay); 
    
printTime();
  }


void SelfTest()
{
 Rr=100;Gg=0;Bb=0; 
 
   for(int i=0;i<109;i++){ 
  pixels.setPixelColor(i, pixels.Color(200,200,200)); // Moderately bright green color.
   pixels.setPixelColor(i-1, pixels.Color(Rr,Gg,Bb)); // Moderately bright green color.
 pixels.show();
 delay(15);

   }

 Rr=0;Gg=1000;Bb=0; 
 
   for(int i=0;i<109;i++){ 
  pixels.setPixelColor(i, pixels.Color(200,200,200)); // Moderately bright green color.
   pixels.setPixelColor(i-1, pixels.Color(Rr,Gg,Bb)); // Moderately bright green color.
 pixels.show();
 delay(20);
   }
    Rr=0;Gg=0;Bb=100; 
 
   for(int i=0;i<109;i++){ 
  pixels.setPixelColor(i, pixels.Color(200,200,200)); // Moderately bright green color.
   pixels.setPixelColor(i-1, pixels.Color(Rr,Gg,Bb)); // Moderately bright green color.
 pixels.show();
 delay(20);
   }
  
 Rr=100;Gg=100;Bb=0; 
 
   for(int i=0;i<109;i++){ 
  pixels.setPixelColor(i, pixels.Color(200,200,200)); // Moderately bright green color.
   pixels.setPixelColor(i-1, pixels.Color(Rr,Gg,Bb)); // Moderately bright green color.
 pixels.show();
 delay(20);
   }

 Rr=0;Gg=100;Bb=100; 
 
   for(int i=0;i<109;i++){ 
  pixels.setPixelColor(i, pixels.Color(200,200,200)); // Moderately bright green color.
   pixels.setPixelColor(i-1, pixels.Color(Rr,Gg,Bb)); // Moderately bright green color.
 pixels.show();
 delay(20);
   }
    Rr=100;Gg=0;Bb=100; 
 
   for(int i=0;i<109;i++){ 
  pixels.setPixelColor(i, pixels.Color(200,200,200)); // Moderately bright green color.
   pixels.setPixelColor(i-1, pixels.Color(Rr,Gg,Bb)); // Moderately bright green color.
 pixels.show();
 delay(20);
   }
  
  }
  





void printTime()
{
  Serial.print(String(rtc.hour()) + ":"); // Print hour
  if (rtc.minute() < 10)
    Serial.print('0'); // Print leading '0' for minute
  Serial.print(String(rtc.minute()) + ":"); // Print minute
  if (rtc.second() < 10)
    Serial.print('0'); // Print leading '0' for second
  Serial.print(String(rtc.second())); // Print second

  if (rtc.is12Hour()) // If we're in 12-hour mode
  {
    // Use rtc.pm() to read the AM/PM state of the hour
    if (rtc.pm()) Serial.print(" PM"); // Returns true if PM
    else Serial.print(" AM");
  }
  
  Serial.print(" | ");

  // Few options for printing the day, pick one:
  Serial.print(rtc.dayStr()); // Print day string
  //Serial.print(rtc.dayC()); // Print day character
  //Serial.print(rtc.day()); // Print day integer (1-7, Sun-Sat)
  Serial.print(" - ");
#ifdef PRINT_USA_DATE
  Serial.print(String(rtc.month()) + "/" +   // Print month  rtc.month()rtc.date()
                 String(rtc.date()) + "/");  // Print date
#else
  Serial.print(String(rtc.date()) + "/" +    // (or) print date
                 String(rtc.month()) + "/"); // Print month
#endif
  Serial.println(String(rtc.year()));        // Print year
}
 
It appears like malloc fails to allocate the buffer for the nexopixels.

So you need to free up some memory.

A good place to start is places like:
Code:
int DayLength[]={
12,12,11,11,11,10,10,9,8,7,6,3,0,0,0,
12,12,11,11,11,10,10,9,9,8,6,4,0,0,0,
12,12,11,11,11,10,10,9,9,8,7,4,0,0,0,
12,12,12,11,11,11,10,10,9,8,7,5,0,0,0,
12,12,12,11,11,11,10,10,9,9,8,6,2,0,0,
12,12,12,11,11,11,10,10,10,9,8,7,4,0,0,
12,12,12,11,11,11,11,10,10,9,9,8,6,0,0,
12,12,12,12,11,11,11,11,10,10,9,9,7,3,0,
12,12,12,12,12,11,11,11,11,10,10,9,8,6,0,
12,12,12,12,12,12,11,11,11,11,11,10,10,8,1,
12,12,12,12,12,12,12,12,12,11,11,11,11,10,8,
12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,
12,12,12,12,12,12,12,12,12,12,13,13,13,13,15,
12,12,12,12,12,12,13,13,13,13,13,14,14,15,20,
12,12,12,12,13,13,13,13,13,13,14,14,15,17,24,
12,12,12,13,13,13,13,13,14,14,14,15,17,20,24,
12,12,12,13,13,13,13,14,14,14,15,16,18,24,24,
12,12,13,13,13,13,14,14,14,15,16,17,19,24,24,
12,12,13,13,13,13,14,14,15,15,16,18,22,24,24,
12,12,13,13,13,14,14,14,15,16,17,19,24,24,24,
12,12,13,13,13,14,14,15,15,16,17,20,24,24,24,
12,12,13,13,13,14,14,15,16,17,18,21,24,24,24,
12,12,13,13,14,14,14,15,16,17,18,22,24,24,24,
12,12,13,13,14,14,15,15,16,17,19,23,24,24,24,
12,12,13,13,14,14,15,15,16,17,19,24,24,24,24,
12,12,13,13,14,14,15,15,16,17,19,24,24,24,24,
12,12,13,13,14,14,15,15,16,17,19,24,24,24,24,
12,12,13,13,14,14,15,15,16,17,18,22,24,24,24,
12,12,13,13,13,14,14,15,16,17,18,21,24,24,24,
12,12,13,13,13,14,14,15,15,16,18,20,24,24,24,
12,12,13,13,13,14,14,15,15,16,17,19,24,24,24,
12,12,13,13,13,14,14,14,15,16,17,18,24,24,24,
12,12,13,13,13,13,14,14,15,15,16,17,20,24,24,
12,12,12,13,13,13,13,14,14,15,15,17,19,24,24,
12,12,12,13,13,13,13,13,14,14,15,16,17,22,24,
12,12,12,12,13,13,13,13,13,14,14,15,16,18,24,
12,12,12,12,12,13,13,13,13,13,14,14,15,16,24,
12,12,12,12,12,12,12,13,13,13,13,13,14,14,17,
12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,
12,12,12,12,12,12,12,12,12,12,12,12,11,11,10,
12,12,12,12,12,12,12,12,11,11,11,11,10,9,6,
12,12,12,12,12,12,11,11,11,11,10,10,9,7,0,
12,12,12,12,11,11,11,11,11,10,10,9,8,5,0,
12,12,12,12,11,11,11,11,10,10,9,8,7,0,0,
12,12,12,11,11,11,11,10,10,9,9,7,5,0,0,
12,12,12,11,11,11,10,10,10,9,8,7,3,0,0,
12,12,12,11,11,11,10,10,9,8,7,6,0,0,0,
12,12,12,11,11,10,10,10,9,8,7,5,0,0,0,
12,12,11,11,11,10,10,9,9,8,6,4,0,0,0,
12,12,11,11,11,10,10,9,9,8,6,3,0,0,0,
12,12,11,11,11,10,10,9,8,7,6,3,0,0,0,
12,12,11,11,11,10,10,9,8,7,6,3,0,0,0,
12,12,11,11,11,10,10,9,8,7,6,3,0,0,0,
12,12,12,11,11,11,11,10,10,9,9,7,5,0,0,
12,12,12,11,11,11,10,10,10,9,8,7,3,0,0,
12,12,12,11,11,11,10,10,9,8,7,6,0,0,0,
12,12,12,11,11,10,10,10,9,8,7,5,0,0,0,
12,12,11,11,11,10,10,9,9,8,6,4,0,0,0,
12,12,11,11,11,10,10,9,9,8,6,3,0,0,0,
12,12,11,11,11,10,10,9,8,7,6,3,0,0,0,
12,12,11,11,11,10,10,9,8,7,6,3,0,0,0,
12,12,11,11,11,10,10,9,8,7,6,3,0,0,0,
};
First it defined as an int array so 4 bytes per entry, yet largest entry is something like 24
So of you define it like:
Code:
int8_t DayLength[]={
It will still be a signed integer of 1 per entry so it cuts by 3/4 size. Also might use uint8_t as well as I don't see any signed stuff.

But better yet, if this ctable does not change, then define it
as const.
Code:
const uint8_t DayLength[] PROGMEM ={
This says the data does not change and as such can stay in code space instead of data space and save up all of that memory for things that change...
Note: Progmem is needed here as on T3.2 this is defined as nothing... But on T4.x this makes a difference.
 
I am curious, the loaded data said this:
Opening Teensy Loader...
Sketch uses 24600 bytes (9%) of program storage space. Maximum is 262144 bytes.
Global variables use 8104 bytes (12%) of dynamic memory, leaving 57432 bytes for local variables. Maximum is 65536 bytes.

so I figured I was now overflowing buffers in my program. testing the change now.(const uint8_t DayLength[] PROGMEM ={)
 
loader data changed after changing int header:
Sketch uses 21812 bytes (8%) of program storage space. Maximum is 262144 bytes.
Global variables use 4384 bytes (6%) of dynamic memory, leaving 61152 bytes for local variables. Maximum is 65536 bytes.
HOPE IT WORKS!! :)
 
the strand tests also can not drive over 110 LEDs, it seems to me that the problem is in the Adafruit_NeoPixel.h> driver

I'm running the Adafruit_NeoPixel strandtest example on Teensy 3.2 right now, with 111 LEDs. Works fine.

I tested both the copy of Adafruit_NeoPixel which Teensyduino bundles, and version 1.7.0 (apparently the most recent) installed by Arduino's library manager. Both work fine.
 
Sounds like you are way out of date. I don't see any official Adafruit releases with that date:

One thing I normally ask in things like this: What version of Arduino IDE? What version of Teensyduino are you running?


Suggestion: Update to the latest Adafruit version:
Two ways to do so:
a) download directly from Adafruit github: https://github.com/adafruit/Adafruit_NeoPixel
b) Use the Arduino Library manager to download the current version: Tools\Manager libraries...
Then choose the Adafruit_neopixel to install or update.
 
Add a syntax error and click Verify. Then look for the info about the full path of the library Arduino used and the ones it ignored (this info is printed on any compiler error, or if you turn on verbose output in File > Prefs). The Adafruit_NeoPixel copy in {Arduino}/hardware/teensy/avr/libraries/Adafruit_NeoPixel is the old but known-good copy Teensyduino installs. I'd recommend deleting all the others. Restart Arduino, so is rescans all your libraries.

Or if you use Tools > Manage Libraries and search for "neopixel", Arduino's library manager will install version 1.7.0. It also lets you replace it with any other version.

But just deleting the messed up copy you're using now is probably all you need. Both 1.7.0 and the version Teensyduino installs both work fine. Just pay close attention to that info Arduino shows about which library it's really using and if there are other copies it's ignoring.
 
thanks for your patience, still not working.
I use an external 5.2V 4Amp PS.
I deleted all neopixel files. opened up the Arduino and Adafruit_NeoPixel.h> was not red.
down loaded: https://github.com/adafruit/Adafruit_NeoPixel.
installed and renamed and Adafruit_NeoPixel.h> is now red.

i am using Arduino 1.8.13


I also DL the Strand test code and it is very constituent, only 110 LEDs work the rest flicker

// NeoPixel test program showing use of the WHITE channel for RGBW
// pixels only (won't look correct on regular RGB NeoPixel strips).

#include <Adafruit_NeoPixel.h>

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN 1

// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 120

// NeoPixel brightness, 0 (min) to 255 (max)
#define BRIGHTNESS 50 // Set BRIGHTNESS to about 1/5 (max = 255)

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_RGB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 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)
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)

void setup() {
// These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
// Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
clock_prescale_set(clock_div_1);
#endif
// END of Trinket-specific code.

strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
strip.show(); // Turn OFF all pixels ASAP
strip.setBrightness(BRIGHTNESS);
}

void loop() {
// Fill along the length of the strip in various colors...
colorWipe(strip.Color(255, 0, 0) , 50); // Red
colorWipe(strip.Color( 0, 255, 0) , 50); // Green
colorWipe(strip.Color( 0, 0, 255) , 50); // Blue
colorWipe(strip.Color( 0, 0, 0, 255), 50); // True white (not RGB white)

whiteOverRainbow(75, 5);

pulseWhite(5);

rainbowFade2White(3, 3, 1);
}

// Fill strip pixels one after another with a color. Strip is NOT cleared
// first; anything there will be covered pixel by pixel. Pass in color
// (as a single 'packed' 32-bit value, which you can get by calling
// strip.Color(red, green, blue) as shown in the loop() function above),
// and a delay time (in milliseconds) between pixels.
void colorWipe(uint32_t color, int wait) {
for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
strip.setPixelColor(i, color); // Set pixel's color (in RAM)
strip.show(); // Update strip to match
delay(wait); // Pause for a moment
}
}

void whiteOverRainbow(int whiteSpeed, int whiteLength) {

if(whiteLength >= strip.numPixels()) whiteLength = strip.numPixels() - 1;

int head = whiteLength - 1;
int tail = 0;
int loops = 3;
int loopNum = 0;
uint32_t lastTime = millis();
uint32_t firstPixelHue = 0;

for(;;) { // Repeat forever (or until a 'break' or 'return')
for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
if(((i >= tail) && (i <= head)) || // If between head & tail...
((tail > head) && ((i >= tail) || (i <= head)))) {
strip.setPixelColor(i, strip.Color(0, 0, 0, 255)); // Set white
} else { // else set rainbow
int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
}
}

strip.show(); // Update strip with new contents
// There's no delay here, it just runs full-tilt until the timer and
// counter combination below runs out.

firstPixelHue += 40; // Advance just a little along the color wheel

if((millis() - lastTime) > whiteSpeed) { // Time to update head/tail?
if(++head >= strip.numPixels()) { // Advance head, wrap around
head = 0;
if(++loopNum >= loops) return;
}
if(++tail >= strip.numPixels()) { // Advance tail, wrap around
tail = 0;
}
lastTime = millis(); // Save time of last movement
}
}
}

void pulseWhite(uint8_t wait) {
for(int j=0; j<256; j++) { // Ramp up from 0 to 255
// Fill entire strip with white at gamma-corrected brightness level 'j':
strip.fill(strip.Color(0, 0, 0, strip.gamma8(j)));
strip.show();
delay(wait);
}

for(int j=255; j>=0; j--) { // Ramp down from 255 to 0
strip.fill(strip.Color(0, 0, 0, strip.gamma8(j)));
strip.show();
delay(wait);
}
}

void rainbowFade2White(int wait, int rainbowLoops, int whiteLoops) {
int fadeVal=0, fadeMax=100;

// Hue of first pixel runs 'rainbowLoops' complete loops through the color
// wheel. Color wheel has a range of 65536 but it's OK if we roll over, so
// just count from 0 to rainbowLoops*65536, using steps of 256 so we
// advance around the wheel at a decent clip.
for(uint32_t firstPixelHue = 0; firstPixelHue < rainbowLoops*65536;
firstPixelHue += 256) {

for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...

// Offset pixel hue by an amount to make one full revolution of the
// color wheel (range of 65536) along the length of the strip
// (strip.numPixels() steps):
uint32_t pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());

// strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or
// optionally add saturation and value (brightness) (each 0 to 255).
// Here we're using just the three-argument variant, though the
// second value (saturation) is a constant 255.
strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue, 255,
255 * fadeVal / fadeMax)));
}

strip.show();
delay(wait);

if(firstPixelHue < 65536) { // First loop,
if(fadeVal < fadeMax) fadeVal++; // fade in
} else if(firstPixelHue >= ((rainbowLoops-1) * 65536)) { // Last loop,
if(fadeVal > 0) fadeVal--; // fade out
} else {
fadeVal = fadeMax; // Interim loop, make sure fade is at max
}
}

for(int k=0; k<whiteLoops; k++) {
for(int j=0; j<256; j++) { // Ramp up 0 to 255
// Fill entire strip with white at gamma-corrected brightness level 'j':
strip.fill(strip.Color(0, 0, 0, strip.gamma8(j)));
strip.show();
}
delay(1000); // Pause 1 second
for(int j=255; j>=0; j--) { // Ramp down 255 to 0
strip.fill(strip.Color(0, 0, 0, strip.gamma8(j)));
strip.show();
}
}

delay(500); // Pause 1/2 second
}
 
Again sorry I am not an expert on how much energy each of those Neopixels draw especially depending on brightness...
But if you for example look at the Adafruit Neopixel learning guide: https://learn.adafruit.com/products/3851/guides

We have a 5V/2A supply that should be able to drive 1 or more meters (depending on use) and a 5V/10A supply that can drive 5 meters (or more, if you are not lighting up all the LEDs at once)
And they are talking about their 32 led per meter.

So using their sort of guidelines their 10amp they suggest for 32*5=160leds so for 120 leds they would suggest: You might need about 7.5 amp... But again I know this is just ballpark number.

What happens if you change brightness to 25?
 
My test hardware here has 1920 LEDs, connected as 8 groups of 240 (meant for testing using OctoWS2811). On the back side are 3 power supplies, each rated for 40 amps.

Adafruit_NeoPixel strandtest with 240 LEDs definitely works when connected to 1 of the 8 sections of that display.
 
My test hardware here has 1920 LEDs, connected as 8 groups of 240 (meant for testing using OctoWS2811). On the back side are 3 power supplies, each rated for 40 amps.

Adafruit_NeoPixel strandtest with 240 LEDs definitely works when connected to 1 of the 8 sections of that display.
So my quick math

(120amp/1920)*120 = 7.5amp... Which is right in line what Adafruit mentioned with their 2amp is good for 1 meter (or 32)...

So again it may be pushing it on 4amp... Wonder if you have volt meter and measure at the far end?
 
Status
Not open for further replies.
Back
Top