For NeoPixel it will call setPixelColor, and for FastLED it will assign values to the leds array. SetAll(red, green, blue); This function sets the entire strip to a give color. You can use it to set the entire strip to a given color or for example with setAll(0,0,0) to black (off). Simple scrolling LED Sign for NeoPixel (WS2811) or LPN8806. If you shop around (ahem, e-Bay), you can find 1 meter long WS2811 LED strips with 60 RGB LEDs for around $8-$9. If you had seven of those, you could make a 60×7 LED sign. It wouldn’t be able to show as many characters at the same time as a BetaBrite does.
When you download the code from github, you'll see a folder called 'examples'. Make sure the 'examples' folder is in your 'Arduino' folder, and is next to the 'libraries' folder--NOT inside of 'libraries'! If your folders are not in the right place, it will not work.
Next, download these libraries:
and put all of these folders inside of your 'libraries' folder. Check the image of my folder structure to make sure yours is similar.
Now it's time to set up your LEDs. The NeoMatrix library gives you several options
for setting up your LED matrix. As you solder your LED strips together, make sure to keep in mind that you'll have to match up the physical configuration of your LEDs and adruino with what you've configured in your code.
for setting up your LED matrix. As you solder your LED strips together, make sure to keep in mind that you'll have to match up the physical configuration of your LEDs and adruino with what you've configured in your code.
Open 'examples', and find 'matrixtest'. Open this file in your arduino IDE.
Near the top of the file, you'll find the line of code that is used to define your matrix object. Here's what mine looks like:
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(5, 7, 3,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
NEO_RGB + NEO_KHZ800);
Here's what that code means:
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix( = 'build me a new matrix'
5 = 'that is 5 pixels wide'
7 = 'and 7 LED strips tall.'
3 = 'I will plug my blue data wire from my LED strips into pin 3 on my arduino.'
NEO_MATRIX_TOP + NEO_MATRIX_LEFT = 'The beginning of my strip, nearest the arduino, is at the top left corner of my matrix.'
NEO_MATRIX_ROWS = 'I'm orienting my strips horizontally, not vertically.'
NEO_MATRIX_ZIGZAG = 'I'm soldering my strips in a zigzag pattern, not a progressive pattern.'
NEO_RGB = 'My strips have RGB LEDs, not GRB LEDs.'
NEO_KHZ800 = 'My strips work at 800KHz.' (These last two will be on the data sheet for the LED strips you bought.)
);
Take a look at the picture of my LEDs, and note:
- I have 5 LEDs per strip on 7 strips
- My arduino is in the top left corner of the matrix
- My blue data wire is soldered to pin 3 on my arduino
- My LED strips are horizontal
- I soldered them together in a 'zigzag' pattern, meaning every other strip is upside-down (more on this next)
Example Arduino code to run a neopixel for my Halloween brain
Halloween_Brain0.1.pde
#include <Adafruit_NeoPixel.h> |
//Hacked from the original Adafruit library demo |
#define PIN6//my control pin |
// Parameter 1 = number of pixels in strip |
// Parameter 2 = pin number (most are valid) |
// Parameter 3 = pixel type flags, add together as needed: |
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) |
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) |
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) |
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) |
Adafruit_NeoPixel strip =Adafruit_NeoPixel(60, PIN, NEO_GRB+NEO_KHZ800); |
voidsetup() { |
strip.begin(); |
strip.show(); // Initialize all pixels to 'off' |
} |
voidloop() { |
//Start out with a pink brain looking color |
colorWipe(strip.Color(255, 48, 48), 1); // Hot Pink |
//Throb read and then fade out |
heartThrob(20); |
} |
// Fill the dots one after the other with a color |
voidcolorWipe(uint32_tc, uint8_twait) { |
for(uint16_t i=0; i<strip.numPixels(); i++) { |
strip.setPixelColor(i, c); |
strip.show(); |
delay(wait); |
} |
} |
voidrainbow(uint8_twait) { |
//secret rainbow mode |
uint16_t i, j; |
for(j=0; j<256; j++) { |
for(i=0; i<strip.numPixels(); i++) { |
strip.setPixelColor(i, Wheel((i+j) &255)); |
} |
strip.show(); |
delay(wait); |
} |
} |
voidheartThrob(uint8_twait) { |
uint16_t i, j; |
//Adjust 60 and 90 to the starting and ending colors you want to fade between. |
for(j=60; j<90; j++) { |
for(i=0; i<strip.numPixels(); i++) { |
strip.setPixelColor(i, Wheel((i+j) &255)); |
} |
strip.show(); |
delay(wait); |
} |
} |
// Input a value 0 to 255 to get a color value. |
// The colours are a transition r - g - b - back to r. |
uint32_t Wheel(byteWheelPos) { |
if(WheelPos<85) { |
returnstrip.Color(WheelPos*3, 255-WheelPos*3, 0); |
} elseif(WheelPos<170) { |
WheelPos-=85; |
returnstrip.Color(255-WheelPos*3, 0, WheelPos*3); |
} else { |
WheelPos-=170; |
returnstrip.Color(0, WheelPos*3, 255-WheelPos*3); |
} |
} |
commented Sep 7, 2018
Is there anyway to update the Flora v1 code to work with Flora V2?? |
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment