NEO PIXELS RANDOM COLOURS

Hi I was wondering if someone is able to help me! I am currently trying to get a strip of 10 neopixels to change colour. I want to be able to code a random neopixel in the strip to change to either red, blue, green or yellow after 2 seconds. I am relatively new to Arduino so I’m still learning. I have been using the code attached and it does everything that I want it to but I would like to set the colour so they’re not as randomised. I found this code online. Hopefully someone can help me cause I’m so confused :confused:

sketch_apr24d.ino (529 Bytes)

No wonder you are confused. You haven't defined the problem. "set the colour so they're not as randomised" says not nearly enough about what you want to do.

Since you have found a sketch that does at least light up pixels, please post again with a clear, complete description of the LED behaviour that you are trying to achieve. How does it differ from the behaviour of sketch that you posted? Please explain both the colour changes you want, and also the timing or any special effects.

Please read these two posts: General Guidance and How to use the Forum and Read this before posting a programming question ...

Welcome. If you post your code using code tags, you get this

#include <Adafruit_NeoPixel.h>

#define PIN 6
#define LED_COUNT 50
Adafruit_NeoPixel strip = Adafruit_NeoPixel(LED_COUNT, PIN, NEO_RGB + NEO_KHZ800);

void setup() {
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop()
{
  randomPixelColor(100);

}

void randomPixelColor(int wait)
{
  int i = random(strip.numPixels());

  uint32_t c = (0, 255, 0); // I have no idea what this crazy number does.
  strip.setPixelColor(i, c);
  strip.show();
  delay(1000);

}    // end void randomPixelColor()

Which makes it easy for people to see your code and help you.

The issue you are having is this line

  uint32_t c = (0, 255, 0); // I have no idea what this crazy number does.

The correct syntax is

    uint32_t c =strip.Color(0, 150, 0);

Those “crazy” numbers are the amount of R/G/B (0-255) so 0,150,0 is moderate Green
Look at the examples that come with the neopixel library