LED Frame with 240 WS2812B programmable LEDs.
Main purpose is to show text animation for information purposes.
There is only one switch button for changing programs.
Parts
1 x Arduino nano or any other clone
240 x WS2812B LED strip
1 x switch button
1 x 5v 5A power supply
Some wires like 22AWG (0.65mm)
1 x Frame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
// http://www.vastahouse.win/index.php/projects/arduino/led-pixel-frame-43-20-x-12/ #include <Adafruit_GFX.h> #include <Adafruit_NeoMatrix.h> #include <Adafruit_NeoPixel.h> #include <Fonts/Org_01.h> #include "Button.h" #include "FastLED.h" #define PIN 3 /* 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) */ // Pushbutton pin definition const int buttonPin = 2; // Digital pin used for debounced pushbutton // int buttonState = 0; // int lastButtonState = 0; Button myBtn(buttonPin, true, true, 50); // Declare the button #define NUM_LEDS 240 #define DATA_PIN 3 CRGB leds[NUM_LEDS]; Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(20, 12, PIN, NEO_MATRIX_BOTTOM + NEO_MATRIX_RIGHT + NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG, NEO_GRB + NEO_KHZ800); const uint16_t colors[] = { matrix.Color(60, 0, 0), matrix.Color(0, 60, 0), matrix.Color(0, 0, 60), matrix.Color(60, 60, 0), matrix.Color(60, 0, 60), matrix.Color(60, 20, 20) }; void setup() { matrix.begin(); matrix.setTextWrap(false); //matrix.setTextSize(1); //matrix.setFont(&Org_01); //matrix.setBrightness(60); matrix.setTextColor(colors[0]); } typedef void (*SimplePatternList[])(); SimplePatternList gPatterns = {picture, joulu, suomi, puola, weddingdate, bday, whiteonly,}; uint8_t gCurrentPatternNumber = 0; int x = matrix.width(); int pass = 0; void loop() { // Call the current pattern function once, updating the 'leds' array gPatterns[gCurrentPatternNumber](); // matrix.show(); delay(20); readbutton(); } void nextPattern() { // add one to the current pattern number, and wrap around at the end gCurrentPatternNumber = (gCurrentPatternNumber + 1); } // TEST PATTERN START void whiteonly() { matrix.setBrightness(255); matrix.fillScreen(matrix.Color(255, 255, 255)); matrix.show(); } // TEST PATTERN STOP //DRAW SHAPES void puola() { matrix.fillScreen(matrix.Color(0, 0, 0)); // matrix.fillScreen(white[pass]); matrix.setBrightness(60); // matrix.fillRect(0,0,6,6,blue[pass]); // matrix.fillRect(4,4,6,6,green[pass]); // matrix.fillRect(10,3,6,6,yellow[pass]); // matrix.fillRect(0,9,5,3,blue[pass]); // matrix.fillRect(5,9,5,3,green[pass]); // matrix.fillRect(10,9,5,3,yellow[pass]); // matrix.fillRect(15,9,5,3,red[pass]); // matrix.drawLine(0, 0, 20, 12,red[pass]); // matrix.drawLine(20, 0, 0, 12,red[pass]); // matrix.fillRect(0,9,5,3,matrix.Color(255, 0, 0)); // matrix.fillRect(5,9,5,3,matrix.Color(0, 255, 0)); // matrix.fillRect(10,9,5,3,matrix.Color(0, 0, 255)); // matrix.fillRect(15,9,5,3,matrix.Color(255, 255, 0)); matrix.fillRect(0,0,20,6,matrix.Color(240, 240, 240)); matrix.fillRect(0,6,20,6,matrix.Color(255, 0, 0)); matrix.show(); } void suomi() { matrix.setBrightness(255); matrix.fillScreen(matrix.Color(240, 240, 240)); matrix.fillRect(5,0,4,12,matrix.Color(0, 0, 255)); matrix.fillRect(0,4,20,4,matrix.Color(0, 0, 255)); matrix.show(); } void weddingdate() { matrix.setBrightness(255); matrix.fillScreen(0); matrix.Color(255, 255, 255); matrix.setCursor(x, 2); matrix.print(F("JOUNI & OLA 13.05.2017 ")); if(--x < -180 // This determines how long text will walk since will be repeated from the beginning. 120=23 characters 160=30 characters. ) { x = matrix.width(); if(++pass >= 1) pass = 0; // This determines how long color array will be played matrix.setTextColor(colors[pass]); } matrix.show(); } void bday() { matrix.setBrightness(255); matrix.fillScreen(0); matrix.setCursor(x, 2); matrix.print(F("HAPPY BIRTHDAY MY LOVE")); if(--x < -180 ) { x = matrix.width(); if(++pass >= 1) pass = 0; matrix.setTextColor(colors[pass]); } matrix.show(); } void readbutton() { // Read the button and increase the mode myBtn.read(); if(myBtn.wasReleased()) { nextPattern(); } } // readbutton() void joulu() { matrix.setBrightness(255); matrix.fillScreen(matrix.Color(40, 0, 0)); matrix.fillRect(1,1,18,10,matrix.Color(0, 0, 0)); matrix.fillRect(9,0,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(9,1,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(8,2,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(10,2,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(8,3,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(10,3,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(3,4,5,1,matrix.Color(40, 40, 0)); matrix.fillRect(11,4,5,1,matrix.Color(40, 40, 0)); matrix.fillRect(4,5,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(14,5,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(5,6,3,1,matrix.Color(40, 40, 0)); matrix.fillRect(11,6,3,1,matrix.Color(40, 40, 0)); matrix.fillRect(7,7,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(11,7,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(6,8,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(9,8,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(12,8,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(6,9,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(8,9,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(10,9,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(12,9,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(6,10,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(7,10,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(11,10,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(12,10,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(6,11,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(12,11,1,1,matrix.Color(40, 40, 0)); matrix.setCursor(x, 2); matrix.print(F("MERRY XMAS HYVAA JOULUA WESOLYCH SWIAT")); if(--x < -300 ) { x = matrix.width(); if(++pass >= 6) pass = 0; matrix.setTextColor(colors[pass]); } matrix.show(); } void picture() { matrix.setBrightness(255); matrix.fillScreen(matrix.Color(40, 0, 0)); matrix.fillRect(1,1,18,10,matrix.Color(0, 0, 0)); matrix.fillRect(9,0,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(9,1,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(8,2,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(10,2,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(8,3,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(10,3,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(3,4,5,1,matrix.Color(40, 40, 0)); matrix.fillRect(11,4,5,1,matrix.Color(40, 40, 0)); matrix.fillRect(4,5,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(14,5,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(5,6,3,1,matrix.Color(40, 40, 0)); matrix.fillRect(11,6,3,1,matrix.Color(40, 40, 0)); matrix.fillRect(7,7,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(11,7,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(6,8,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(9,8,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(12,8,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(6,9,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(8,9,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(10,9,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(12,9,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(6,10,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(7,10,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(11,10,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(12,10,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(6,11,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(12,11,1,1,matrix.Color(40, 40, 0)); matrix.fillRect(5,2,1,1,matrix.Color(0, 0, 20)); matrix.fillRect(15,2,1,1,matrix.Color(0, 0, 20)); matrix.fillRect(16,9,1,1,matrix.Color(0, 0, 20)); matrix.fillRect(3,8,1,1,matrix.Color(0, 0, 20)); matrix.show(); } |