Advertisement
Makerino

ticker

Mar 23rd, 2020
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.62 KB | None | 0 0
  1. #include <SPI.h>
  2. #include <Adafruit_GFX.h>
  3. #include <Max72xxPanel.h>
  4.  
  5. int pinCS = 10; // Attach CS to this pin, DIN to MOSI and CLK to SCK (cf http://arduino.cc/en/Reference/SPI )
  6. int numberOfHorizontalDisplays = 1;
  7. int numberOfVerticalDisplays = 4;
  8.  
  9. Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
  10.  
  11. String tape = "mak3r.in0";
  12. int wait = 50; // In milliseconds
  13.  
  14. int spacer = 1;
  15. int width = 5 + spacer; // The font width is 5 pixels
  16.  
  17. void setup() {
  18.   matrix.setRotation(3);
  19.   matrix.setIntensity(7); // Use a value between 0 and 15 for brightness
  20.  
  21. // Adjust to your own needs
  22. //  matrix.setPosition(0, 0, 0); // The first display is at <0, 0>
  23. //  matrix.setPosition(1, 1, 0); // The second display is at <1, 0>
  24. //  matrix.setPosition(2, 2, 0); // The third display is at <2, 0>
  25. //  matrix.setPosition(3, 3, 0); // And the last display is at <3, 0>
  26. //  ...
  27. //  matrix.setRotation(0, 2);    // The first display is position upside down
  28. //  matrix.setRotation(3, 2);    // The same hold for the last display
  29. }
  30.  
  31. void loop() {
  32.  
  33.   for ( int i = 0 ; i < width * tape.length() + matrix.width() - 1 - spacer; i++ ) {
  34.  
  35.     matrix.fillScreen(LOW);
  36.  
  37.     int letter = i / width;
  38.     int x = (matrix.width() - 1) - i % width;
  39.     int y = (matrix.height() - 8) / 2; // center the text vertically
  40.  
  41.     while ( x + width - spacer >= 0 && letter >= 0 ) {
  42.       if ( letter < tape.length() ) {
  43.         matrix.drawChar(x, y, tape[letter], HIGH, LOW, 1);
  44.       }
  45.  
  46.       letter--;
  47.       x -= width;
  48.     }
  49.  
  50.     matrix.write(); // Send bitmap to display
  51.  
  52.     delay(wait);
  53.   }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement