SHARE
TWEET

arduino

mrzombie80 Nov 19th, 2019 105 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. #include <SPI.h>        
  4. #include <DMD.h>        
  5. #include <TimerOne.h>  
  6. #include "SystemFont5x7.h"
  7. #include "Arial_black_16.h"
  8.  
  9. //Fire up the DMD library as dmd
  10. #define DISPLAYS_ACROSS 3
  11. #define DISPLAYS_DOWN 1
  12. DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);
  13.  
  14. void ScanDMD()
  15. {
  16.  dmd.scanDisplayBySPI();
  17. }
  18.  
  19.  
  20. void setup(void)
  21. {  
  22.   Timer1.initialize( 5000 );          
  23.   Timer1.attachInterrupt( ScanDMD );    
  24.   dmd.clearScreen( true );  
  25.  
  26.   Serial.begin(9600);
  27. }
  28.  
  29.  
  30. void loop(void)
  31. {
  32.   dmd.clearScreen( true );
  33.  // dmd.selectFont(Arial_Black_16);
  34.   dmd.selectFont(System5x7);
  35.  
  36. char teks[] = "Scrolling Text";
  37. int lebarTeks = 0;
  38. for (int i = 0; i < sizeof(teks)+1; i++) {
  39.   lebarTeks += dmd.charWidth(teks[i]) + 1;
  40. }
  41.  
  42. dmd.drawBox(  0,  0, (32*DISPLAYS_ACROSS)-1, (16*DISPLAYS_DOWN)-1, GRAPHICS_NORMAL );
  43. int i = 0;
  44. while(true) {
  45.   dmd.drawString ((lebarTeks+10)-i, 3, teks, sizeof(teks), GRAPHICS_NORMAL);
  46.   dmd.drawBox(  0,  0, (32*DISPLAYS_ACROSS)-1, (16*DISPLAYS_DOWN)-1, GRAPHICS_NORMAL );
  47.   Serial.println(i);
  48.   delay(100);
  49.   if(i >= 180) {
  50.     i = 0;
  51.   }
  52.   i++;
  53. }
  54.  
  55. }
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
 
Top