Thanks! I was trying to wrap my head around doing that, I was thinking....and correct me if this won't work, I was going to use int to make 5 integers for each color and then try and use random to switch between each defined int. The other part is trying to make 1-5 a random color and 6-10 a different color.
I do not have an arduino board, I was using a tutorial online that used a pro trinket for cosplay props, so I bought that for the small size so I can hide it inside somewhere.
@cyborgkangaroo, your topic has been moved to a more suitable location. Introductory Tutorials is not for questions but for tutorials that e.g. you write. Feel free to write one once you have mastered your problem
Can you please spend some time reading How to get the best out of this forum and in future use code tags when posting code. We would also prefer it if you post full code so (in this case) we know which library you're using.
Do you know how to control an individual led in the strip? Have a look at e.g. the blink example that comes with the FastLed library. The below is a modified example for a strip with 10 leds.
#include <FastLED.h>
// How many leds in your strip?
#define NUM_LEDS 10
// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
#define DATA_PIN 3
#define CLOCK_PIN 13
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}
void loop()
{
// set the colours
for (int cnt = 0; cnt < 5; cnt++)
{
leds[cnt] = CRGB::Red;
}
for (int cnt = 5; cnt < 10; cnt++)
{
leds[cnt] = CRGB::Blue;
}
// and show
FastLED.show();
delay(500);
// clear the strip
for (int cnt = 0; cnt < 10; cnt++)
{
leds[cnt] = CRGB::Black;
}
FastLED.show();
delay(500);
}
My apologies, did not know I was in the wrong section, I have used the blink example for the on board light, I will give this one a try, thank you so much.
Ok, I looked at the guide for the code tags, sorry about that. Did not realize the code tags made things easier to read on the forum haha I did use the tag in the beginning and also auto formatted the code before pasting.
This is what I got so far, I have the lights cycling through blue,fading in and then out and repeating, but don't know how to make multiple rainbowCycles with the different colors and then having a random function choose 1 of the 5 colors to cycle through and then loop the random function again after a delay.
[code]
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(10, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
// This is for Trinket 5V 16MHz,
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
rainbowCycle(10);
}
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on wheel
for (i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}
// Currently setup to slowly fade the blue LEDs down the strip
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if (WheelPos < 85) {
return strip.Color(0, 0, WheelPos * 3);
}
if (WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, 0, 255 - WheelPos * 3);
}
WheelPos -= 170;
return strip.Color(0, 0, 0);
}
[/code]
If your problem is solved, please tick the solution checkbox under the most useful reply; that way others that have a similar problem can know that a solution was provided / the problem was solved.