Can't use on-board neopixels with external neopixels

Play with it! Please tell us which board you're using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
monguin
 
Posts: 3
Joined: Wed Mar 09, 2016 8:14 pm

Can't use on-board neopixels with external neopixels

Post by monguin »

Pretty straightforward problem, minimal example in code below. Is this expected? Is there a different way to set up an external strip on this board? I found this https://learn.adafruit.com/neopixels-wi ... nal-strips, but didn't find a corresponding C example.

I also seem to have trouble using the accelerometer simultaneously with the external strip.

I'm using an old-style Circuit Playground Classic, and the strip is on pin 12. It's powered by laptop USB, and the external strip stays lit with no trouble, just won't update. The system is soldered together so it's tricky to test other pins, but I can re-solder if necessary.

Code: Select all

#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_NeoPixel.h> 
#define PIN    12
#define N 32
Adafruit_NeoPixel estrip = Adafruit_NeoPixel(N, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  estrip.begin();
  estrip.setBrightness(64);
  CircuitPlayground.begin();  // if this is commented, the external strip works. if uncommented, on-board works and external doesn't.
}

int t=0;
void loop() {
  for(int n=0; n<10; n++) {
    CircuitPlayground.setPixelColor(n, Wheel(t%256));
  }
  
  int speed=10;
  for(int i=0; i<N; i++) {
      estrip.setPixelColor(i, Wheel(t%256));
  }  
  estrip.show();
  delay(100);
  t++;
}


User avatar
adafruit_support_carter
 
Posts: 29152
Joined: Tue Nov 29, 2016 2:45 pm

Re: Can't use on-board neopixels with external neopixels

Post by adafruit_support_carter »

The code seems OK. Sounds like it's not working though. Can you posts a photo of your setup showing how the external strip is attached to the Circuit Playground Classic.

User avatar
monguin
 
Posts: 3
Joined: Wed Mar 09, 2016 8:14 pm

Re: Can't use on-board neopixels with external neopixels

Post by monguin »

everything
everything
cp.jpg (998.78 KiB) Viewed 161 times
Kind of tricky to show all the connections in a photo, but it's like this:

- VBATT -> red -> ring power
- GND -> black -> ring ground
- #12 -> blue -> ring data

All going through a JST connector (which I now realize I could use to test a different strip, I'll try that).

I'm not sure how people normally solder to these things, I'm used to smaller holes, so I wrapped the wire around the board and loaded it up with solder. The other solder joint looks like these two.
joint closeup
joint closeup
IMG_9506.25.jpg (455.5 KiB) Viewed 161 times

User avatar
adafruit_support_carter
 
Posts: 29152
Joined: Tue Nov 29, 2016 2:45 pm

Re: Can't use on-board neopixels with external neopixels

Post by adafruit_support_carter »

Thanks for the photos. Cool googles.

The pads were mainly designed for use with alligator clips, so there's no real standard way to solder to them. What you've done is fine.

Let's try a simple test code the exercises just the external strip. And just the first pixel. Try running this:

Code: Select all

#include <Adafruit_NeoPixel.h>
#define PIN 12
#define N 1
Adafruit_NeoPixel estrip = Adafruit_NeoPixel(N, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  estrip.begin();
  estrip.fill(0x00ff00);
  estrip.show();
}

void loop() {
}
and see if the first pixel in the ring set turns green.

User avatar
monguin
 
Posts: 3
Joined: Wed Mar 09, 2016 8:14 pm

Re: Can't use on-board neopixels with external neopixels

Post by monguin »

Thanks!

That method doesn't seem to exist, not sure if that's a version problem? I've never used fill before.

Code: Select all

exit status 1
'class Adafruit_NeoPixel' has no member named 'fill'
However, the following both compiles and runs as expected:

Code: Select all

#include <Adafruit_NeoPixel.h>
#define PIN 12
#define N 1
Adafruit_NeoPixel estrip = Adafruit_NeoPixel(N, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  estrip.begin();
  estrip.setPixelColor(0,0x00ff00);
  estrip.show();
}

void loop() {}
Also, I found I can set any static color/brightness I want, on both strips, with some conditions. I'm not 100% sure, but it seems like calling CircuitPlayground.begin(); prevents any further updates to the external strip. This almost makes sense to me; the external strip requires calling show() in the main loop, but calling CircuitPlayground.setPixelColor() updates immediately. Maybe if I could somehow control the attached pixels with the same Adafruit_NeoPixel library, the strips could play nicely together?

Edit: Not exactly sure what the problem is, but I found https://github.com/adafruit/Adafruit_Ci ... xel.h#L110 and tried this, which seems to solve my problem:

Code: Select all

Adafruit_NeoPixel istrip = Adafruit_NeoPixel(10, 17, NEO_GRB + NEO_KHZ800);
Thanks for making this stuff available open source!

Maybe I can figure out how to do something similar for the accelerometer and the other devices on the board. Using that istrip definition above, all the pixels work perfectly. But, as soon as the code reaches CircuitPlayground.motionX(), all light animations and button controls stop working.

Can you point me in the right direction to understand what I'm looking at here: https://github.com/adafruit/Adafruit_Ci ... DH.cpp#L36? This is some of the code that interfaces with the accelerometer, but I'm not familiar with some of the syntax. That is, I'm vaguely familiar with C++, and I've done some microcontroller assembly programming, but I've never used C++ for embedded work.

User avatar
adafruit_support_carter
 
Posts: 29152
Joined: Tue Nov 29, 2016 2:45 pm

Re: Can't use on-board neopixels with external neopixels

Post by adafruit_support_carter »

Check your version of the NeoPixel library. The fill function should be there:
https://github.com/adafruit/Adafruit_Ne ... xel.h#L132
I did a test compile of that sketch for a Circuit Playground Classic target and it compiled fine for me.

The line of code you linked is the default constructor. The next line:
https://github.com/adafruit/Adafruit_Ci ... DH.cpp#L37
is setting default values for those member variables. I'm not super fond of that syntax. It makes the code compact, but can not be the most readable. It's equivalent to:

Code: Select all

Adafruit_CPlay_LIS3DH::Adafruit_CPlay_LIS3DH()
{
  _cs = -1;
  _mosi = -1;
  _miso = -1;
  _sck = -1;
  _sensorID = -1;
}

Locked
Please be positive and constructive with your questions and comments.

Return to “Circuit Playground Classic, Circuit Playground Express, Circuit Playground Bluefruit”