Lighting the RGB LED: Difference between revisions

From Banana Pi Wiki
Jump to navigation Jump to search
legacy>Hulkwang
legacy>Hulkwang
No edit summary
Line 21: Line 21:
[[File:LightingLED-2.png]]
[[File:LightingLED-2.png]]


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


   #define PIN            6
   #define PIN            6
   #define NUMPIXELS      16
   #define NUMPIXELS      16


change to
* change to


   #define PIN            4
   #define PIN            4
Line 32: Line 33:
   #define LED_POWER      2
   #define LED_POWER      2


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


   pinMode(LED_POWER, OUTPUT);
   pinMode(LED_POWER, OUTPUT);
   digitalWrite(LED_POWER, HIGH);
   digitalWrite(LED_POWER, HIGH);


Compile this program
* Compile this program


[[File:LightingLED-3.png]]
[[File:LightingLED-3.png]]


And download it(Set the serial port and board)
And download it(Set the serial port and board)

Revision as of 14:56, 29 August 2018

How to lighting the RGB LED

Install Library

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


  1. Install Library by Manage Libraries:
 
 File:LightingLED-5.png
 

Programe Code

  • Open Arduino IDE

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


  • We need to change some code,Find the code below in the code
 #define PIN            6
 #define NUMPIXELS      16
  • change to
 #define PIN            4
 #define NUMPIXELS      25
 #define LED_POWER      2
  • Then add the following code to void setup()
  pinMode(LED_POWER, OUTPUT);
  digitalWrite(LED_POWER, HIGH);
  • Compile this program

And download it(Set the serial port and board)