Advertisement
Guest User

Untitled

a guest
Jul 19th, 2014
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. //We always have to include the library
  2. #include "LedControlMS.h"
  3.  
  4. /*
  5. Now we need a LedControl to work with.
  6. ***** These pin numbers will probably not work with your hardware *****
  7. pin 12 is connected to the DataIn
  8. pin 11 is connected to the CLK
  9. pin 10 is connected to LOAD
  10. We have only a single MAX72XX.
  11. */
  12. #define NBR_MTX 2
  13. LedControl lc=LedControl(12,11,10, NBR_MTX);
  14.  
  15. String digits= "1234567890";
  16. int digitCounter=0;
  17. /* we always wait a bit between updates of the display */
  18. unsigned long delaytime=300;
  19.  
  20.  
  21. void setup() {
  22. /*
  23. The MAX72XX is in power-saving mode on startup,
  24. we have to do a wakeup call
  25. */
  26. Serial.begin (9600);
  27. Serial.println("Setup");
  28. digitCounter=0;
  29. for (int i=0; i< NBR_MTX; i++){
  30. lc.shutdown(i,false);
  31. /* Set the brightness to a medium values */
  32. lc.setIntensity(i,8);
  33. /* and clear the display */
  34. lc.clearDisplay(i);
  35. }
  36.  
  37. Serial.println("LED0: 0 0");
  38. lc.setLed(0,0,0,true);
  39. delay(1000);
  40. Serial.println("LED0: 0 7");
  41. lc.setLed(0,0,7,true);
  42. delay(1000);
  43. Serial.println("LED0: 7 0");
  44. lc.setLed(0,7,0,true);
  45. delay(1000);
  46. Serial.println("LED0: 7 7");
  47. lc.setLed(0,7,7,true);
  48. delay(1000);
  49. Serial.println("LED0: 0 0 off");
  50. lc.setLed(0,0,0,false);
  51. delay(1000);
  52. Serial.println("LED0: 0 7 off");
  53. lc.setLed(0,0,7,false);
  54. delay(1000);
  55. Serial.println("LED0: 7 0 off");
  56. lc.setLed(0,7,0,false);
  57. delay(1000);
  58. Serial.println("LED0: 7 7 off");
  59. lc.setLed(0,7,7,false);
  60. delay(1000);
  61. //clearAll();
  62.  
  63. lc.setRow(0,1,0x0C);
  64. delay(1000);
  65. lc.clearDisplay(0);
  66. lc.setRow(0,1,0xC0);
  67. delay(1000);
  68. lc.clearDisplay(0);
  69.  
  70. lc.setColumn(0,1,0x0C);
  71. delay(1000);
  72. lc.clearDisplay(0);
  73. lc.setColumn(0,1,0xC0);
  74. delay(1000);
  75. lc.clearDisplay(0);
  76.  
  77. lc.writeString(0,"Hola Mundo");
  78. delay(1000);
  79. lc.clearAll();
  80. scrollLeft('O');
  81. delay(1000);
  82. lc.clearAll();
  83. scrollRight('O');
  84. delay(1000);
  85. lc.clearAll();
  86.  
  87. }
  88.  
  89.  
  90. void loop() {
  91. char ch= digits[digitCounter];
  92. digitCounter++;
  93. if (digitCounter>9) digitCounter=0;
  94. lc.displayChar(0, lc.getCharArrayPosition(ch));
  95. delay(1000);
  96. lc.clearAll();
  97. delay(200);
  98. }
  99.  
  100.  
  101. void scrollLeft(char ch){
  102. int pos =lc.getCharArrayPosition(ch);
  103. for (int scroll =0; scroll<6; scroll++) {
  104. for (int i=scroll; i<6;i++) {
  105. lc.setRow(0,i-scroll, alphabetBitmap[pos][i]);
  106. }
  107. delay(300);
  108. lc.clearDisplay(0);
  109. }
  110. }
  111.  
  112. void scrollRight(char ch){
  113. int pos =lc.getCharArrayPosition(ch);
  114. for (int scroll =0; scroll<8; scroll++) {
  115. for (int i=0; i<6;i++) {
  116. if (scroll+i<8) lc.setRow(0, scroll+i, alphabetBitmap[pos][i]);
  117. }
  118. delay(300);
  119. lc.clearDisplay(0);
  120. }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement