LPD8806 Project Help Needed

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

LPD8806 Project Help Needed

Postby lpgordon » Sun Feb 19, 2012 12:34 am

Hello All,

I've been having a lot of fun experimenting with the LPD8806 strip, but need some help with a project.

I downloaded the sample code and a lot of other code that's out there but can't quite figure out how to do what I need.

Basically, I'd like the whole strip (32 LED's) to be one color. Then I'd like to control the color with a potentiometer (or possibly 3 potentiometers for RGB) so that turning the pot cycles through all of the colors.

I'm not looking for all of the code, just some suggestions on which function would be best to control the strip. And a general idea of how to code in the potentiometer.
lpgordon
 
Posts: 3
Joined: Sun Feb 19, 2012 12:14 am

Re: LPD8806 Project Help Needed

Postby elmerfud » Mon Feb 20, 2012 6:11 pm

For your pot code... I believe the resolution on the analog inputs of the arduino is 10 bits. (someone correct me if I'm wrong). So just calling a read to see their current position and bit shifting it down to 7-bits per color should get you where you need to be on that.

For setting the whole strip to the same color something as simple as this should do it.

Code: Select all
for (i=0; i < strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
}
strip.show();
elmerfud
 
Posts: 20
Joined: Wed Feb 01, 2012 5:28 pm

Re: LPD8806 Project Help Needed

Postby pounce » Wed Feb 22, 2012 12:03 am

I think if you are setting the entire strip to the same color there are cheaper strips and eassier methods using pwm.

Think about using rotary encoders and isr's

Using potentiometers you can use map() to um map to 7 bit color .
pounce
 
Posts: 82
Joined: Wed Nov 23, 2011 5:36 pm

Re: LPD8806 Project Help Needed

Postby lpgordon » Wed Feb 22, 2012 6:41 pm

Thanks everyone for the advice.

The code above worked well for displaying one color.

I wasn't aware of map() but it looks like what I'm looking for and I'll give it a try tonight. I'm also going to look into rotary encoders.
lpgordon
 
Posts: 3
Joined: Sun Feb 19, 2012 12:14 am

Re: LPD8806 Project Help Needed

Postby lpgordon » Fri Mar 02, 2012 9:31 pm

Here's what I came up with. I didn't use map() but instead did some math. It seems to work fine.

I will be using this as a part of a bigger project. Thanks everyone for the input.


Code: Select all
//  Sketch to adjust color of LPD8806 using 3 potentiometers. 

#include "LPD8806.h"
#include "SPI.h"


int dataPin = 2;   
int clockPin = 3;

int redpotPin = 3;      // Potentiometer for red LED output connected to analog pin 3
int greenpotPin = 2;    //  green
int bluepotPin = 1;     //  blue


int redpotVal = 0; // variable to store the input from the red potentiometer
int greenpotVal = 0;  //  green
int bluepotVal = 0;  // blue


int redVal = 0;    // variable to store value color value
int greenVal = 0;  //  green
int blueVal = 0;   //  blue

LPD8806 strip = LPD8806(32, dataPin, clockPin);



void setup()


{
  // Start up the LED strip
  strip.begin();

  // Update the strip, to start they are all 'off'
  strip.show();
}


void loop() {
 
  redpotVal = analogRead(redpotPin);   // read the red potentiometer value at the input pin
  greenpotVal = analogRead(greenpotPin);  // green
  bluepotVal = analogRead(bluepotPin);    // blue
 
   
 
  redVal = redpotVal / 10;         //  normalize pot value to LED
  greenVal = greenpotVal / 10;     //  green
  blueVal = bluepotVal / 10;       //  blue
 
 
  colorChase(strip.Color(redVal,greenVal,blueVal), 10);   

}


void colorChase(uint32_t c, uint8_t wait) {
  int i;
 
  for (i=0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, 0);
  }
 
  for (i=0; i < strip.numPixels(); i++) {   
      strip.setPixelColor(i, c);               
                                               
      }
      strip.show();
      delay(wait);
  }
lpgordon
 
Posts: 3
Joined: Sun Feb 19, 2012 12:14 am

Re: LPD8806 Project Help Needed

Postby blackrock » Tue May 01, 2012 9:48 am

I dont understand how this is wired...? There are 3 potentiometers but they all connect via 1 pin? please explain?
blackrock
 
Posts: 1
Joined: Tue May 01, 2012 9:47 am

Re: LPD8806 Project Help Needed

Postby pburgess » Tue May 01, 2012 12:45 pm

They're on three different pins: analog 1 through 3. (Lines 10-12 in the sketch, but only the first in the list is fully commented.)
User avatar
pburgess
 
Posts: 1327
Joined: Sun Oct 26, 2008 1:29 am


Return to Arduino

Who is online

Users browsing this forum: No registered users and 12 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [105]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]