Hi I have a led strip that uses LPD8806 + Fastled 3.1
On my Arduino uno I have set the digital data pin to 2 and the clock pin to 3 and this works fine.
I wanted to make a mood lamp so wanted a smaller board to put the code on - so I bought an Arduino Leonardo Pro micro.
I tested the blink code to test that everything was ok and that worked fine on the Leonardo Pro micro, so I uploaded my sketch from my Arduino Uno to the Leonardo Pro micro - but it's not driving the led strip - just all the lights are white?
The digital pins are supposed to be the same and are numbered 2+3 so I thought the code would work fine. The Leonardo Pro micro has a 16mhz crystal and is 5v so the timing should be the same as the uno, here's the code:
#include <FastLED.h>
#define BRIGHTNESS 255 // 0-255, higher number is brighter.
#define SATURATION 255 // 0-255, 0 is pure white, 255 is fully saturated color
#define SPEED 15 // How fast the colors move. Higher numbers = faster motion
#define STEPS 4 // How wide the bands of color are. 1 = more like a gradient, 10 = more like stripes
#define BUTTON_PIN 13 // switch leds modes
#define DATA_PIN 2 // Connect Led Stip Data Pin to this
#define CLK_PIN 3 // Connect Led Stip Clock Pin to this
#define LED_TYPE LPD8806
#define COLOR_ORDER BRG // Changes the colour order if leds display incorrectly - can be RGB/BRG/GBR etc...
#define NUM_LEDS 52 // Number of LED on our strip
CRGB leds[NUM_LEDS];
CRGBPalette16 currentPalette;
CRGBPalette16 targetPalette( RainbowStripeColors_p );
TBlendType currentBlending;
int ledMode = 0;
// Start of confetti variables
int thishue = 50;
uint8_t thisinc = 1;
uint8_t thissat = 100;
uint8_t thisfade = 20;
int huediff = 256;
uint8_t thisbri = 255;
// End of confetti variables
unsigned long keyPrevMillis = 0;
const unsigned long keySampleIntervalMs = 25;
byte longKeyPressCountMax = 80; // 80 * 25 = 2000 ms
byte longKeyPressCount = 0;
byte prevKeyState = HIGH; // button is active low
void setup()
{
delay(1000); // power-up safety delay
FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
currentBlending = LINEARBLEND;
pinMode(BUTTON_PIN, INPUT_PULLUP);
}
//=====================================Start of main void loop=====================================
void loop()
{
byte currKeyState = digitalRead(BUTTON_PIN);
if ((prevKeyState == LOW) && (currKeyState == HIGH))
{
shortKeyPress();
}
prevKeyState = currKeyState;
switch (ledMode)
{
case 0:
rainbowstripe();
break;
case 1:
forest();
break;
case 2:
ocean();
break;
case 3:
purple();
break;
case 4:
rainbow();
break;
case 5:
heat();
break;
case 6:
party();
break;
case 7:
lava();
break;
case 8:
dude();
break;
case 9:
Sparkels();
break;
case 10:
juggle();
break;
case 11:
pinkdots();
break;
case 12:
confetti();
break;
}
FastLED.show();
}
//=====================================End of main void loop=====================================
void sequence()
{ //this was removed from the main loop so that other sequences would work properly
static uint8_t startIndex = 0;
startIndex = startIndex + 1; /* motion speed */
// Above here was at the top of the loop
// Below here was at the bottom of the loop
FillLEDsFromPaletteColors( startIndex);
FastLED.delay(1000 / SPEED);
}
void shortKeyPress()
{
ledMode++;
if (ledMode > 13)
{ // The more effects you add to the void loop - increase this number by 1 for each case added
ledMode=0;
}
}
void rainbowstripe()
{
sequence();
currentPalette = RainbowStripeColors_p; //Red & Yellow, Fire Colors
}
void forest()
{
sequence();
currentPalette = ForestColors_p; //Foresty greens and yellows
}
void ocean()
{
sequence();
currentPalette = OceanColors_p; //Oceans are pretty and filled with mermaids
}
void purple()
{
sequence();
currentPalette = PurpleColors_p; //Custom pallete
}
void rainbow()
{
sequence();
currentPalette = RainbowColors_p; //All the colors!
}
void heat()
{
sequence();
currentPalette = HeatColors_p; //Rainbow stripes
}
void party()
{
sequence();
currentPalette = PartyColors_p; //All the colors except the greens, which make people look a bit washed out
}
void lava()
{
sequence();
currentPalette = LavaColors_p; //Set everything lava
}
void dude()
{
sequence();
currentPalette = DudeColors_p; //Set everything lava
}
void Sparkels()
{
fadeToBlackBy( leds, NUM_LEDS, 42);
int i = random16(NUM_LEDS);
leds[i] += CHSV( random(), 255, 255);
FastLED.delay(100 / SPEED);
}
void FillLEDsFromPaletteColors( uint8_t colorIndex)
{
for( int i = 0; i < NUM_LEDS; i++)
{
leds[i] = ColorFromPalette(currentPalette, colorIndex, BRIGHTNESS, currentBlending);
colorIndex += STEPS;
}
}
void juggle()
{
// eight colored dots, weaving in and out of sync with each other
fadeToBlackBy( leds, NUM_LEDS, 20);
byte dothue = 0;
for( int i = 0; i < 8; i++)
{
leds[beatsin16(i+7,0,NUM_LEDS)] |= CHSV(dothue, 200, 255);
dothue += 32;
}
}
void pinkdots() //Pink dots moving from left to right with a trail
{
fadeToBlackBy( leds, NUM_LEDS, 0); //change this to change the trail length.
int pos = beatsin16(10,0,NUM_LEDS); //change this to adjust the speed.
leds[pos] += CHSV( 240, 240, 240);
}
void confetti()
{
uint8_t secondHand = (millis() / 1000) % 15; // IMPORTANT!!! Change '15' to a different value to change duration of the loop.
static uint8_t lastSecond = 99; // Static variable, means it's only defined once. This is our 'debounce' variable.
if (lastSecond != secondHand)
{ // Debounce to make sure we're not repeating an assignment.
lastSecond = secondHand;
switch(secondHand)
{
case 0: thisinc=1; thishue=192; thissat=255; thisfade=2; huediff=256; break; // You can change values here, one at a time , or altogether.
case 5: thisinc=2; thishue=128; thisfade=8; huediff=64; break;
case 10: thisinc=1; thishue=random16(255); thisfade=1; huediff=16; break; // Only gets called once, and not continuously for the next several seconds. Therefore, no rainbows.
case 15: break; // Here's the matching 15 for the other one.
}
}
fadeToBlackBy(leds, NUM_LEDS, thisfade); // Low values = slower fade.
int pos = random16(NUM_LEDS); // Pick an LED at random.
leds[pos] += CHSV((thishue + random16(huediff))/4 , thissat, thisbri); // I use 12 bits for hue so that the hue increment isn't too quick.
thishue = thishue + thisinc; // It increments here.
}
Any ideas as to why it's not working?
Thanks