Lets try and give the required detail:
I am using the following Addressable RGB Leds
The code is as follows and is taken from an example online I have left the name of the originator with thanks and hope this is acceptable - I have edited it to remove a tone generator part as I don't want that:
// Addressable RGB LED Demo Sketch
// Dain Unicorn August 25, 2014
// If this code is of use to you, please make use of it, and let me know what your doing with it.
// This code is original to me, with references from the Arduino Example for generating Tones.
// A Special Thank you to the folks at Adafruit for their fine NeoPixel library that makes this sketch possible.
// And show some love to the folks at SparkFun where I got these 8mm Addressable RGB LEDs.
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel strip = Adafruit_NeoPixel(5, 6, NEO_RGB + NEO_KHZ800);
// The three parameters passed here are: Number of LEDs, Arduino Pin, Config information.
// For more help on the Config details, see the Example sketch provided with the Adafruit NeoPixel library.
void setup() {
// When power is first applied to the LEDs they will show a color based on the voltage being sent to them. For the 5VDC
// power from an Arduino Uno, it is a moderate blue color. This is a normal function of the WS2812 chip when it doesn't have
// data to use.
strip.begin();
strip.show();
// We initalize the NeoPixel Library here, by starting it and then sending the first strip.show() command.
// Next we will tell all of the LEDs to switch off before continuing.
pcr(); // PixelColorsReset function, it turns all of the LEDs completely off.
// This custom function can be found at the bottom of this Sketch.
// We play the melody once during setup with all 5 LEDs lighting up in the color for the tone being played.
strip.setPixelColor(0, 0, 0, 0);
strip.setPixelColor(1, 220, 20, 60);
strip.setPixelColor(2, 220, 20, 60);
strip.setPixelColor(3, 220, 20, 60);
strip.setPixelColor(4, 220, 20, 60);
strip.show();
pcr();
// We don't need a delay at the end here, as the next iteration of the loop delays at the start.
}
void loop() {
// The melody has played in the setup loop, so we will play it again and again getting faster every time until its too fast.
notes(); // this custom function plays the tones with only one LED lighting up per tone.
// The function itself is at the bottom of this Sketch.
// Once the wait varible is less than 40 we will play the melody one last time, with all the LEDs lit and at a set duration.
// Then increment the ending varible so that the Sketch goes dark and silent until reset.
delay(2500);
strip.setPixelColor(0, 220, 20, 60);
strip.setPixelColor(1, 220, 20, 60);
strip.setPixelColor(2, 220, 20, 60);
strip.setPixelColor(3, 220, 20, 60);
strip.setPixelColor(4, 220, 20, 60);
strip.show();
pcr();
}
void pcr() {
// This function turns all the LEDs off, reseting them.
// I wrote this function to overcome the only real shortcomming I saw in the Adafruit Library, a reset command.
strip.setPixelColor(0, 0, 0, 0);
strip.setPixelColor(1, 0, 0, 0);
strip.setPixelColor(2, 0, 0, 0);
strip.setPixelColor(3, 0, 0, 0);
strip.setPixelColor(4, 0, 0, 0);
strip.show();
return;
}
void notes() {
// This function plays the melody, lighting up only the LED that corresponds to the tone played.
pcr();
strip.setPixelColor(0, 100, 0, 0);
strip.setPixelColor(1, 0, 0, 0);
strip.setPixelColor(2, 0, 0, 0);
strip.setPixelColor(3, 0, 0, 0);
strip.setPixelColor(4, 0, 0, 0);
strip.show();
strip.setPixelColor(0, 0, 0, 0);
strip.setPixelColor(1, 170, 80, 10);
strip.setPixelColor(2, 0, 0, 0);
strip.setPixelColor(3, 0, 0, 0);
strip.setPixelColor(4, 0, 0, 0);
strip.show();
pcr();
return;
}
When I load this the LEDs come on very bright and white with no colour change. If you have any tips that would be great.
I have tried resistors in line but this has not helped.
Thanks I hope this helps and meets your site rules. I am seeking to develop a code and layout for use in the classroom.