Difference between revisions of "LED Control with LPD8806 Library + Arduino"

From ESE205 Wiki
Jump to: navigation, search
(Created page with "==Getting Started== The LPD8806 library is used to control LPD8806/LPD8803/LPD8809 PWM LED driver chips, strips and pixels. The link for downloading and instructions for insta...")
 
(Creating an instance of the LPD8806 class)
Line 9: Line 9:
  
 
example:
 
example:
<source lang="c++">LPD8806 strip1 = LPD8806(48, 51, 52)//creates an LPD8806 object to control 48 lights, with data pin on 51, and clock pin on 52</source>
+
<source lang = "c">LPD8806 strip1 = LPD8806(48, 51, 52)//creates an LPD8806 object to control 48 lights, with data pin on 51, and clock pin on 52</source>
  
*<source lang="c++">LPD8806(uint16_t n)</source>
+
*<code>LPD8806(uint16_t n)</code>
 
This constructor takes in the number of LEDs to control, and relies on the Arduino's hardware SPI.  These pins vary for each Arduino, so make sure you have it connected to the right pins.
 
This constructor takes in the number of LEDs to control, and relies on the Arduino's hardware SPI.  These pins vary for each Arduino, so make sure you have it connected to the right pins.
  
exsample:
+
example:
<source lang="c++">LPD8806 strip1 = LPD8806(48)//creates an LPD8806 object with Arduino SPI pins, (ie, on the Arduino Mega, these pins are 51 for the data pin and 52 for the clock pin)</source>
+
<source lang = "c">LPD8806 strip2 = LPD8806(48)//creates an LPD8806 object with Arduino SPI pins, (ie, on the Arduino Mega, these pins are 51 for the data pin and 52 for the clock pin)</source>
  
 
*<source lang="c++">LPD8806()</source>
 
*<source lang="c++">LPD8806()</source>
This is a blank constructor, you must set the number of LEDs, data and clock pin separately using <code>updatePins(uint8_t dpin, uint8_t cpin)</code>.
+
This is a blank constructor, you must set the number of LEDs, data and clock pin separately using <code>updatePins(uint8_t dpin, uint8_t cpin)</code>, <code>updatePins() //for hardware SPI</code>, and <code>updateLength(uint16_t n)</code>.
 +
 
 +
example:
 +
<source lang = "c">
 +
LPD8806 strip3 = new LPD8806(); //create LPD8806 object
 +
strip3.updatePins(51,52); //set data pin to 51, clock pin to 52
 +
strip3.updateLength(48); //set length to 48
 +
</source>

Revision as of 15:30, 1 May 2017

Getting Started

The LPD8806 library is used to control LPD8806/LPD8803/LPD8809 PWM LED driver chips, strips and pixels. The link for downloading and instructions for installing the library can be found here. [1]

Creating an instance of the LPD8806 class

The LPD8806 library has three constructors:

  • LPD8806(uint16_t n, uint8_t dpin, uint8_t cpin)
    

This constructor takes in the number of LEDs in the strip, the data pin (port on arduino connected to DI), and the clock pin (port on arduino connected to CI).

example:

LPD8806 strip1 = LPD8806(48, 51, 52)//creates an LPD8806 object to control 48 lights, with data pin on 51, and clock pin on 52
  • LPD8806(uint16_t n)

This constructor takes in the number of LEDs to control, and relies on the Arduino's hardware SPI. These pins vary for each Arduino, so make sure you have it connected to the right pins.

example:

LPD8806 strip2 = LPD8806(48)//creates an LPD8806 object with Arduino SPI pins, (ie, on the Arduino Mega, these pins are 51 for the data pin and 52 for the clock pin)
  • LPD8806()
    

This is a blank constructor, you must set the number of LEDs, data and clock pin separately using updatePins(uint8_t dpin, uint8_t cpin), updatePins() //for hardware SPI, and updateLength(uint16_t n).

example:

LPD8806 strip3 = new LPD8806(); //create LPD8806 object
strip3.updatePins(51,52); //set data pin to 51, clock pin to 52
strip3.updateLength(48); //set length to 48