slurry bowl
Active member
I have experience running LPD8806 code on an Arduino UNO.
I am trying to run the same code on my TEENSY 2.0++ and its not working, yet.
I know I need B1=clock and B2=data
Where would I assign these within the code? Here is my current code for mapping between 2 colors on a strip with 80 LEDs:
#include "LPD8806.h"
#include "SPI.h"
// Number of RGB LEDs in strand:
int nLEDs = 80;
// Chose 2 pins for output; can be any valid output pins:
int dataPin = 2;
int clockPin = 1;
// Magenta:
#define COLOR1_R 0
#define COLOR1_G 0
#define COLOR1_B 120
// Blue:
#define COLOR2_R 0
#define COLOR2_G 120
#define COLOR2_B 0
LPD8806 strip = LPD8806(80, dataPin, clockPin);
void setup() {
// Start up the LED strip
strip.begin();
// Update the strip, to start they are all 'off'
strip.show();
}
void loop()
{
int r,g,b;
int rA, gA, bA, rB, gB, bB;
uint16_t i, j, k, l, m;
for (j=0; j < 140; j++) // fade over a range of 140 steps
{
// calculate pixels 0-39 color
int rA = map(j, 0, 140, COLOR1_R, COLOR2_R);
int gA = map(j, 0, 140, COLOR1_G, COLOR2_G);
int bA = map(j, 0, 140, COLOR1_B, COLOR2_B);
// calculate pixels 40-79 color
int rB = map(j, 0, 140, COLOR2_R, COLOR1_R);
int gB = map(j, 0, 140, COLOR2_G, COLOR1_G);
int bB = map(j, 0, 140, COLOR2_B, COLOR1_B);
for (i=0; i < 30; i++)
{
strip.setPixelColor(i,(strip.Color(rA,gA,bA) )); // set pixels 0-39
strip.setPixelColor(i + 30,(strip.Color(rB,gB,bB) )); // set pixels 40-79
}
strip.show(); // write all pixels to the strip
delay(1); // pause to appreciate...
}
for (j=0; j < 140; j++) // fade over a range of 140 steps
{
// calculate pixels 0-39 color
int rA = map(j, 0, 140, COLOR2_R, COLOR1_R);
int gA = map(j, 0, 140, COLOR2_G, COLOR1_G);
int bA = map(j, 0, 140, COLOR2_B, COLOR1_B);
// calculate pixels 40-79 color
int rB = map(j, 0, 140, COLOR1_R, COLOR2_R);
int gB = map(j, 0, 140, COLOR1_G, COLOR2_G);
int bB = map(j, 0, 140, COLOR1_B, COLOR2_B);
for (i=0; i < 30; i++)
{
strip.setPixelColor(i,(strip.Color(rA,gA,bA) )); // set pixels 0-39
strip.setPixelColor(i + 30,(strip.Color(rB,gB,bB) )); // set pixels 40-79
}
strip.show(); // write all pixels to the strip
delay(1); // pause to appreciate...
}
}
I am trying to run the same code on my TEENSY 2.0++ and its not working, yet.
I know I need B1=clock and B2=data
Where would I assign these within the code? Here is my current code for mapping between 2 colors on a strip with 80 LEDs:
#include "LPD8806.h"
#include "SPI.h"
// Number of RGB LEDs in strand:
int nLEDs = 80;
// Chose 2 pins for output; can be any valid output pins:
int dataPin = 2;
int clockPin = 1;
// Magenta:
#define COLOR1_R 0
#define COLOR1_G 0
#define COLOR1_B 120
// Blue:
#define COLOR2_R 0
#define COLOR2_G 120
#define COLOR2_B 0
LPD8806 strip = LPD8806(80, dataPin, clockPin);
void setup() {
// Start up the LED strip
strip.begin();
// Update the strip, to start they are all 'off'
strip.show();
}
void loop()
{
int r,g,b;
int rA, gA, bA, rB, gB, bB;
uint16_t i, j, k, l, m;
for (j=0; j < 140; j++) // fade over a range of 140 steps
{
// calculate pixels 0-39 color
int rA = map(j, 0, 140, COLOR1_R, COLOR2_R);
int gA = map(j, 0, 140, COLOR1_G, COLOR2_G);
int bA = map(j, 0, 140, COLOR1_B, COLOR2_B);
// calculate pixels 40-79 color
int rB = map(j, 0, 140, COLOR2_R, COLOR1_R);
int gB = map(j, 0, 140, COLOR2_G, COLOR1_G);
int bB = map(j, 0, 140, COLOR2_B, COLOR1_B);
for (i=0; i < 30; i++)
{
strip.setPixelColor(i,(strip.Color(rA,gA,bA) )); // set pixels 0-39
strip.setPixelColor(i + 30,(strip.Color(rB,gB,bB) )); // set pixels 40-79
}
strip.show(); // write all pixels to the strip
delay(1); // pause to appreciate...
}
for (j=0; j < 140; j++) // fade over a range of 140 steps
{
// calculate pixels 0-39 color
int rA = map(j, 0, 140, COLOR2_R, COLOR1_R);
int gA = map(j, 0, 140, COLOR2_G, COLOR1_G);
int bA = map(j, 0, 140, COLOR2_B, COLOR1_B);
// calculate pixels 40-79 color
int rB = map(j, 0, 140, COLOR1_R, COLOR2_R);
int gB = map(j, 0, 140, COLOR1_G, COLOR2_G);
int bB = map(j, 0, 140, COLOR1_B, COLOR2_B);
for (i=0; i < 30; i++)
{
strip.setPixelColor(i,(strip.Color(rA,gA,bA) )); // set pixels 0-39
strip.setPixelColor(i + 30,(strip.Color(rB,gB,bB) )); // set pixels 40-79
}
strip.show(); // write all pixels to the strip
delay(1); // pause to appreciate...
}
}