Neopixel Code Help - RESOLVED

Hi there folks,

Been having a little problem with my neopixel code unfortunately. I have flashed it successfully several times and have determined that it’s not the photon (other code works perfectly well on it). Forgive me for my noobishness.

I have a photon plugged into a shield shield for 3.3v -> 5v Logic shifting and a single neopixel hooked into the shield on pin 7, 5v and gnd (just like an arduino) and have tried changing the pin used for data. I can’t get it to react to any of the code I have loaded.

Now, I’m pretty experienced with the arduino neopixel library and I generally know all the correct use of functions, but I’m still sort of new to the particle firmware coming over from arduino, so I stuck with simple and tried to turn my single neopixel red.

Here is my code:

// This #include statement was automatically added by the Particle IDE.
#include "neopixel/neopixel.h"

//Strip Defenition
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, 7, WS2812);

//Colors
uint32_t red = strip.Color(255, 0, 0);
uint32_t orange = strip.Color(255, 128, 0);
uint32_t yellow = strip.Color(255, 255, 0);
uint32_t green = strip.Color(0, 255, 0);
uint32_t light_blue = strip.Color(0, 255, 255);
uint32_t blue = strip.Color(0, 0, 255);
uint32_t purple = strip.Color(127, 0, 255);

void setup() {
    strip.begin();
    strip.setBrightness(255);
    strip.show();
}

void loop() {
    strip.setPixelColor(1, red);
    strip.show();
    delay(1000);
    /* commented out for a single color
    strip.setPixelColor(1, orange);
    strip.show();
    delay(1000);
    
    strip.setPixelColor(1, yellow);
    strip.show();
    delay(1000);
    
    strip.setPixelColor(1, green);
    strip.show();
    delay(1000);
    
    strip.setPixelColor(1, light_blue);
    strip.show();
    delay(1000);
    
    strip.setPixelColor(1, blue);
    strip.show();
    delay(1000);
    
    strip.setPixelColor(1, purple);
    strip.show();
    delay(1000);
*/
}

The library included is the latest available from here https://github.com/technobly/SparkCore-NeoPixel

I think you've just got a simple fencepost error. The first pixel is at index 0, not 1. So this should be:

strip.setPixelColor(0, red);

Give that a shot!

Unfortunately that did not accomplish the job, though that was a really dumb mistake

It’s a shot in the dark (literally, since that pixel isn’t lighting), but have you tried the other pixel types in Adafruit_NeoPixel(1, 7, WS2812)?

The available types (per this line of code) are:

  • WS2812
  • WS2812B
  • WS2811
  • TM1803

I have tried all the different settings, but it's even dumber than that :smiley:
So, what I didn't realize is how the pins were mapped to the shield shield, which means what I thought was digital pin 2 turned out to be analog pin 2(?) what? I'm not sure who thought of that, but ok I guess.

Anyway, thank you for trying to troubleshoot my stupid!

2 Likes

I bet you can’t find a single member of this forum who hasn’t done that at least twice! I’m glad you got it figured out!