Hi AskFriends,
(see also the Arduino LED effect article)
When using the FastLED library, you could do something like this:
#include "FastLED.h"
#define NUM_LEDS 60 // Number of LEDs in your ELD strip
CRGB leds[NUM_LEDS];
#define PIN 6 // Arduino pin used for LED strip
void setup()
{
FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}
void loop() {
for(int i = 0; i < NUM_LEDS; i++ ) {
leds[Pixel].r = 0x00; // Red
leds[Pixel].g = 0x00; // Green
leds[Pixel].b = 0xFF; // Blue
}
FastLED.show();
}
For AdaFruit NeoPixel library something like this:
#include
#define PIN 6 // Arduino PIN
#define NUM_LEDS 60 // Number of LEDs in strip
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
for(int i = 0; i < NUM_LEDS; i++ ) {
strip.setPixelColor(Pixel, strip.Color(0, 0, 0xff));
}
strip.show();
}
(Note: updated code, replace red, green and blue with numbers)
Hope this helps