Go Down

Topic: Adafruit Neopixels Don't Work (Read 474 times) previous topic - next topic

ajgrinds

Jun 16, 2018, 07:53 pm Last Edit: Jun 16, 2018, 07:57 pm by ajgrinds
Hey guys!

I a trying to make neopixel rings a solid color and its not working. The code uploads just fine. I'm using These LEDS and I've used a nano, uno and mega. The tools are selected and the port is fine.

I've tried uploading blink to the arduino and it works.
I've gotten a new strip, PC, cable and arduino.
I haven't gotten an error

Here is my test code (IK this won't be one color)
Code: [Select]
#include <Adafruit_NeoPixel.h>
 
#define PIN      4
#define N_LEDS 12
 
Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_RGBW + NEO_KHZ800);
 
void setup() {
  strip.begin();
}
 
void loop() {
  chase(strip.Color(255, 0, 0)); // Red
  chase(strip.Color(0, 255, 0)); // Green
  chase(strip.Color(0, 0, 255)); // Blue
}
 
static void chase(uint32_t c) {
  for(uint16_t i=0; i<strip.numPixels()+4; i++) {
      strip.setPixelColor(i  , c); // Draw new pixel
      strip.setPixelColor(i-4, 0); // Erase pixel a few steps back
      strip.show();
      delay(25);
  }
}


and

My real code:
Code: [Select]
#include <Adafruit_NeoPixel.h>

#define PIN 4
#define NUMPIXELS 12

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_RGBW + NEO_KHZ800);
uint32_t Red = (255,0,0,0);
uint32_t Green = (0,255,0,0);
uint32_t Blue = (0,0,255,0);
uint32_t Yellow = (255,255,0,0);
uint32_t Purple = (128,0,128,0);
uint32_t LightBlue = (135,206,250,0);
uint32_t UglyGreen = (61,128,14,0);


uint32_t White = (0,0,0,255);
int currentState = 0;
void setup() {
  // put your setup code here, to run once:
  strip.begin();
  //strip.show();
  Serial.begin(115200);
}
void Solid(uint32_t Color){
  for(int i = 0; i < NUMPIXELS; i++)
  {
    strip.setPixelColor(i,Color);
  }
  strip.show();
}
void loop() {
currentState = Serial.read();
  // put your main code here, to run repeatedly:
switch(currentState){
  case 0:
     Solid(Blue);
  case 1:
    Solid(Red);
  case 2:
    Solid(Yellow);
  case 3:
    Solid(Green);
  case 4:
    Solid(LightBlue);
  case 5:
    Solid(LightBlue);
  case 9:
    Solid(White);
  default:
    Solid(UglyGreen);
}
}   

ieee488

I am pretty sure the Neopixels work.

It is code that doesn't!


.

ajgrinds

Thats why I looked for the test code, which also doesn't work.

ieee488

#3
Jun 16, 2018, 09:31 pm Last Edit: Jun 16, 2018, 09:31 pm by ieee488
Thats why I looked for the test code, which also doesn't work.
use Adafruit's code; not yours!


.

Rintin


Edgar1

Just a general idea: Test the simple things first and then expand your code.
I.e. first light just one LED. No variables, just plain numbers.
When that does not work look if you selected the correct LED type, pin, is the power ok, etc.
Look until you find the problem(s).

After that work you can expand your code. If you are not an expert then probably it's best to expand it part by part. After one part works work on the next etc.

That may take a little longer but it's less stressful. It's nice to have these "this part work, done", work, "that part works as well, done" experiences.

You will figure it out eventually.


Go Up