SHARE
TWEET

Untitled

a guest Oct 21st, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Arduino.h>
  2. #include <SPI.h>
  3. #include <Max72xxPanel.h>
  4. #include <Adafruit_GFX.h>
  5.  
  6. #define BUZZER_PIN  D2
  7. const boolean WEBSERVER_ENABLED = true;  // Device will provide a web interface
  8. boolean ENABLE_OTA = true;
  9. String OTA_Password = "";
  10. int displayScrollSpeed = 25;
  11.  
  12. void scrollMessage();
  13.  
  14. const int pinCS = D6; // Attach CS to this pin, DIN to MOSI and CLK to SCK (cf http://arduino.cc/en/Reference/SPI )
  15. int displayIntensity = 1;  //(Can be set from 0 - 15)
  16. const int numHorizontalDisplays = 8; // default 4 for standard 4 x 1 display Max size of 16
  17. const int numVerticalDisplays = 1; // default 1 for a single row height
  18. /* set ledRotation for LED Display panels (3 is default)
  19. 0: no rotation
  20. 1: 90 degrees clockwise
  21. 2: 180 degrees
  22. 3: 90 degrees counter clockwise (default)
  23. */
  24. int ledRotation = 3;
  25.  
  26. // LED
  27. const int offset = 1;
  28. int refresh = 0;
  29. int spacer = 1;  // dots between letters
  30. int width = 5 + spacer; // The font width is 5 pixels + spacer
  31. Max72xxPanel matrix = Max72xxPanel(pinCS, numHorizontalDisplays, numVerticalDisplays);
  32.  
  33. void setup(void){
  34.   Serial.begin(115200);
  35.   delay(10);
  36.   Serial.println('\n');
  37.  
  38.   Serial.println("Number of LED Displays: " + String(numHorizontalDisplays));
  39.   // initialize display
  40.   matrix.setIntensity(0); // Use a value between 0 and 15 for brightness
  41.  
  42.   int maxPos = numHorizontalDisplays * numVerticalDisplays;
  43.   for (int i = 0; i < maxPos; i++) {
  44.     matrix.setRotation(i, ledRotation);
  45.     matrix.setPosition(i, maxPos - i - 1, 0);
  46.   }
  47.  
  48.   Serial.println("matrix created");
  49.   matrix.fillScreen(LOW); // show black
  50.  
  51.   /*tone(BUZZER_PIN, 415, 500);
  52.   delay(500 * 1.3);
  53.   tone(BUZZER_PIN, 466, 500);
  54.   delay(500 * 1.3);
  55.   tone(BUZZER_PIN, 370, 1000);
  56.   delay(1000 * 1.3);
  57.   noTone(BUZZER_PIN);*/
  58.  
  59.   for (int inx = 0; inx <= 15; inx++) {
  60.     matrix.setIntensity(inx);
  61.     delay(100);
  62.   }
  63.  
  64.   for (int inx = 15; inx >= 0; inx--) {
  65.     matrix.setIntensity(inx);
  66.     delay(60);
  67.   }
  68.  
  69.   delay(1000);
  70.   matrix.setIntensity(displayIntensity);
  71.  
  72. }
  73.  
  74. void loop(void){
  75.   scrollMessage();
  76.   delay(10000);
  77. }
  78.  
  79. void scrollMessage() {
  80.   String msg = "olala";
  81.   msg += " "; // add a space at the end
  82.   for ( unsigned int i = 0 ; i < width * msg.length() + matrix.width() - 1 - spacer; i++ ) {
  83.  
  84.     if (refresh == 1) i = 0;
  85.     refresh = 0;
  86.     matrix.fillScreen(LOW);
  87.  
  88.     unsigned int letter = i / width;
  89.     int x = (matrix.width() - 1) - i % width;
  90.     int y = (matrix.height() - 8) / 2; // center the text vertically
  91.  
  92.     while ( x + width - spacer >= 0 && letter >= 0 ) {
  93.       if ( letter < msg.length() ) {
  94.         matrix.drawChar(x, y, msg[letter], HIGH, LOW, 1);
  95.       }
  96.  
  97.       letter--;
  98.       x -= width;
  99.     }
  100.  
  101.     matrix.write(); // Send bitmap to display
  102.     delay(displayScrollSpeed);
  103.   }
  104.   matrix.setCursor(0, 0);
  105. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top