Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.65 KB | None | 0 0
  1. // Adafruit_NeoMatrix example for tiled NeoPixel matrices. Scrolls
  2. // 'Howdy' across three 10x8 NeoPixel grids that were created using
  3. // NeoPixel 60 LEDs per meter flex strip.
  4.  
  5. #include <Adafruit_GFX.h>
  6. #include <Adafruit_NeoMatrix.h>
  7. #include <Adafruit_NeoPixel.h>
  8. #ifndef PSTR
  9. #define PSTR // Make Arduino Due happy
  10. #endif
  11.  
  12. #define PIN 6
  13.  
  14. // MATRIX DECLARATION:
  15. // Parameter 1 = width of EACH NEOPIXEL MATRIX (not total display)
  16. // Parameter 2 = height of each matrix
  17. // Parameter 3 = number of matrices arranged horizontally
  18. // Parameter 4 = number of matrices arranged vertically
  19. // Parameter 5 = pin number (most are valid)
  20. // Parameter 6 = matrix layout flags, add together as needed:
  21. // NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT:
  22. // Position of the FIRST LED in the FIRST MATRIX; pick two, e.g.
  23. // NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
  24. // NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs WITHIN EACH MATRIX are
  25. // arranged in horizontal rows or in vertical columns, respectively;
  26. // pick one or the other.
  27. // NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns WITHIN
  28. // EACH MATRIX proceed in the same order, or alternate lines reverse
  29. // direction; pick one.
  30. // NEO_TILE_TOP, NEO_TILE_BOTTOM, NEO_TILE_LEFT, NEO_TILE_RIGHT:
  31. // Position of the FIRST MATRIX (tile) in the OVERALL DISPLAY; pick
  32. // two, e.g. NEO_TILE_TOP + NEO_TILE_LEFT for the top-left corner.
  33. // NEO_TILE_ROWS, NEO_TILE_COLUMNS: the matrices in the OVERALL DISPLAY
  34. // are arranged in horizontal rows or in vertical columns, respectively;
  35. // pick one or the other.
  36. // NEO_TILE_PROGRESSIVE, NEO_TILE_ZIGZAG: the ROWS/COLUMS OF MATRICES
  37. // (tiles) in the OVERALL DISPLAY proceed in the same order for every
  38. // line, or alternate lines reverse direction; pick one. When using
  39. // zig-zag order, the orientation of the matrices in alternate rows
  40. // will be rotated 180 degrees (this is normal -- simplifies wiring).
  41. // See example below for these values in action.
  42. // Parameter 7 = pixel type flags, add together as needed:
  43. // NEO_RGB Pixels are wired for RGB bitstream (v1 pixels)
  44. // NEO_GRB Pixels are wired for GRB bitstream (v2 pixels)
  45. // NEO_KHZ400 400 KHz bitstream (e.g. FLORA v1 pixels)
  46. // NEO_KHZ800 800 KHz bitstream (e.g. High Density LED strip)
  47.  
  48. // Example with three 10x8 matrices (created using NeoPixel flex strip --
  49. // these grids are not a ready-made product). In this application we'd
  50. // like to arrange the three matrices side-by-side in a wide display.
  51. // The first matrix (tile) will be at the left, and the first pixel within
  52. // that matrix is at the top left. The matrices use zig-zag line ordering.
  53. // There's only one row here, so it doesn't matter if we declare it in row
  54. // or column order. The matrices use 800 KHz (v2) pixels that expect GRB
  55. // color data.
  56. Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(10, 8, 3, 1, PIN,
  57. NEO_TILE_TOP + NEO_TILE_LEFT + NEO_TILE_ROWS + NEO_TILE_PROGRESSIVE +
  58. NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
  59. NEO_GRB + );
  60.  
  61. const uint16_t colors[] = {
  62. matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) };
  63.  
  64. void setup() {
  65. matrix.begin();NEO_KHZ800
  66. matrix.setTextWrap(false);
  67. matrix.setBrightness(40);
  68. matrix.setTextColor(colors[0]);
  69. }
  70.  
  71. int x = matrix.width();
  72. int pass = 0;
  73.  
  74. void loop() {
  75. matrix.fillScreen(0);
  76. matrix.setCursor(x, 0);
  77. matrix.print(F("Howdy"));
  78. if(--x < -36) {
  79. x = matrix.width();
  80. if(++pass >= 3) pass = 0;
  81. matrix.setTextColor(colors[pass]);
  82. }
  83. matrix.show();
  84. delay(100);
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement