Lighting the RGB LED: Difference between revisions

From Banana Pi Wiki
Jump to navigation Jump to search
legacy>Jh
legacy>Jh
 
Line 23: Line 23:
* We need to change some code,Find the code below in the code
* We need to change some code,Find the code below in the code


const uint16_t PixelCount = 4; // this example assumes 4 pixels, making it smaller will cause a failure
  const uint16_t PixelCount = 4; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin = 2;  // make sure to set this to the correct pin, ignored for Esp8266
  const uint8_t PixelPin = 2;  // make sure to set this to the correct pin, ignored for Esp8266


* change to
* change to


const uint16_t PixelCount = 25; // this example assumes 4 pixels, making it smaller will cause a failure
  const uint16_t PixelCount = 25; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin = 4;  // make sure to set this to the correct pin, ignored for Esp8266
  const uint8_t PixelPin = 4;  // make sure to set this to the correct pin, ignored for Esp8266




* Then add the following code to void setup()
* Then add the following code to void setup()


#define LED_POWER      2
  #define LED_POWER      2
pinMode(LED_POWER, OUTPUT);
  pinMode(LED_POWER, OUTPUT);
digitalWrite(LED_POWER, HIGH);
  digitalWrite(LED_POWER, HIGH);


* Compile this program
* Compile this program

Latest revision as of 14:49, 1 October 2018

How to lighting the RGB LED

Install Library

  1. Install library from github:
  • Librarys:[NeoPixel_Bus] from Makuna
  • Download libraries and put it in the libraries folder in the installation directory of the Arduino IDE
 


  1. Install Library by Manage Libraries:
 
 

Programe Code

  • Open Arduino IDE

click 'file'->'Example'->'NeoPixel Bus'->'simple' to open the example

  • We need to change some code,Find the code below in the code
 const uint16_t PixelCount = 4; // this example assumes 4 pixels, making it smaller will cause a failure
 const uint8_t PixelPin = 2;  // make sure to set this to the correct pin, ignored for Esp8266
  • change to
 const uint16_t PixelCount = 25; // this example assumes 4 pixels, making it smaller will cause a failure
 const uint8_t PixelPin = 4;  // make sure to set this to the correct pin, ignored for Esp8266


  • Then add the following code to void setup()
 #define LED_POWER      2
 pinMode(LED_POWER, OUTPUT);
 digitalWrite(LED_POWER, HIGH);
  • Compile this program

And download it(Set the serial port and board)