The number of articles discussing folks reveling in the science and fun of celebrating Pi on March 14th has exploded. People of all ages are going gaga with those who like science or just some fun coming out to celebrate in many way. Celebrations often involve making and eating Pie the dessert, due to the similarity in pronunciation between Pi and Pie.
Wikipedia public domain by GJ_on_Wiki |
Wikipedia CC BY-SA 3.0 Holger Motzkau |
// Program for Flexible 8x32 NeoPixel RGB LED Matrix
// Scrolls text across the matrix
//
// Mike Barela 3/12/2015 MIT License, attribution appreciated
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#define PIN 12 // NeoPixel data pin on Uno
// MATRIX DECLARATION:
// Parameter 1 = width of NeoPixel matrix
// Parameter 2 = height of matrix
// Parameter 3 = pin number (most are valid)
// Parameter 4 = matrix layout flags, add together as needed:
// NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT:
// Position of the FIRST LED in the matrix; pick two, e.g.
// NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
// NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal
// rows or in vertical columns, respectively; pick one or the other.
// NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed
// in the same order, or alternate lines reverse direction; pick one.
// See example below for these values in action.
// Parameter 5 = 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)
// Example for Flexible 8x32 NeoPixel RGB LED Matrix. In this application we'd like to use it
// as a 32x8 tall matrix. When held that way, the first pixel is at the top right, and
// lines are arranged in columns, progressive order. The shield uses
// 800 KHz (v2) pixels that expect GRB color data.
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG, NEO_GRB + NEO_KHZ800);
const uint16_t colors[] = {
matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) };
void setup() {
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(35);
}
int x = matrix.width();
void loop() {
matrix.fillScreen(0);
matrix.setCursor(x, 0);
matrix.setTextColor(colors[1]);
matrix.print(F("Happy "));
matrix.setTextColor(colors[0]);
matrix.print(F("Pi "));
matrix.setTextColor(colors[1]);
matrix.print(F("Day "));
matrix.setTextColor(colors[2]);
matrix.print(F("3.14.15 "));
if(--x < -(22*5)) { // Scrolling code - 22 characters, 5 pixels wide
x = matrix.width();
}
matrix.show();
delay(100);
}
Be sure you have a power supply big enough to power that many Neopixels. I used Adafruit's 5V 10 amp supply but a 2 amp supply at the lower brightness might suffice, 5 amps might be a good size.
If you cannot get an Adafruit matrix, a couple (or more!) Wyolum TiM LED matrices would also be very good for a similar marquee.
Have a happy and safe Pi Day!
No comments:
Post a Comment