p22_8x8RedLEDMatrixDriver.ino 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. Demo code of P22 - 8x8 Red LED Matrix Driver
  3. by maker studio
  4. */
  5. #include "TM1638.h"
  6. TM1638 LED_Matrix(4,5,6);
  7. uint8_t lineDat = 0b11011100;
  8. uint8_t columeDat = 0b11011100;
  9. //demo pic
  10. uint8_t picDat0[] ={ 0b11111111,
  11. 0b10000001,
  12. 0b10000001,
  13. 0b10000001,
  14. 0b10000001,
  15. 0b10000001,
  16. 0b10000001,
  17. 0b11111111};
  18. uint8_t picDat1[] ={ 0b00000000,
  19. 0b01111110,
  20. 0b01000010,
  21. 0b01000010,
  22. 0b01000010,
  23. 0b01000010,
  24. 0b01111110,
  25. 0b00000000};
  26. uint8_t picDat2[] ={ 0b00000000,
  27. 0b00000000,
  28. 0b00111100,
  29. 0b00100100,
  30. 0b00100100,
  31. 0b00111100,
  32. 0b00000000,
  33. 0b00000000};
  34. uint8_t picDat3[] ={ 0b00000000,
  35. 0b00000000,
  36. 0b00000000,
  37. 0b00011000,
  38. 0b00011000,
  39. 0b00000000,
  40. 0b00000000,
  41. 0b00000000};
  42. void setup()
  43. {
  44. LED_Matrix.displayAll();
  45. delay(500);
  46. LED_Matrix.clear();
  47. }
  48. void loop()
  49. {
  50. int line =0;
  51. int colume = 0;
  52. //test set point
  53. for(line = 0; line < 8;){
  54. for(colume = 0; colume < 8; colume++){
  55. LED_Matrix.setPoint(line,colume,1);
  56. delay(50);
  57. }
  58. line++;
  59. for(colume = 7; colume >= 0; colume--){
  60. LED_Matrix.setPoint(line,colume,1);
  61. delay(50);
  62. }
  63. line++;
  64. }
  65. //test clear display
  66. LED_Matrix.clear();
  67. delay(500);
  68. //test set line
  69. for(line = 0; line < 8; line++){
  70. LED_Matrix.displayLine(line);
  71. delay(50);
  72. }
  73. for(line = 7; line >= 0; line--){
  74. LED_Matrix.clearLine(line);
  75. delay(50);
  76. }
  77. for(line = 0; line < 8; line++){
  78. LED_Matrix.setLine(line,lineDat);
  79. delay(50);
  80. }
  81. for(line = 7; line >= 0; line--){
  82. LED_Matrix.clearLine(line);
  83. delay(50);
  84. }
  85. delay(500);
  86. //test set colume
  87. //test set line
  88. for(colume = 0; colume < 8; colume++){
  89. LED_Matrix.displayColume(colume);
  90. delay(50);
  91. }
  92. for(colume = 7; colume >= 0; colume--){
  93. LED_Matrix.clearColume(colume);
  94. delay(50);
  95. }
  96. for(colume = 0; colume < 8; colume++){
  97. LED_Matrix.setColume(colume,columeDat);
  98. delay(50);
  99. }
  100. for(colume = 7; colume >= 0; colume--){
  101. LED_Matrix.clearColume(colume);
  102. delay(50);
  103. }
  104. delay(500);
  105. //test display pic
  106. LED_Matrix.displayPic(picDat0);
  107. delay(150);
  108. LED_Matrix.displayPic(picDat1);
  109. delay(150);
  110. LED_Matrix.displayPic(picDat2);
  111. delay(150);
  112. LED_Matrix.displayPic(picDat3);
  113. delay(150);
  114. LED_Matrix.displayPic(picDat2);
  115. delay(150);
  116. LED_Matrix.displayPic(picDat1);
  117. delay(150);
  118. LED_Matrix.displayPic(picDat0);
  119. delay(500);
  120. //
  121. for(colume = 0; colume < 8; colume++){
  122. LED_Matrix.setPoint(0,colume,1);
  123. delay(50);}
  124. for(line = 1; line < 8;line++);{
  125. LED_Matrix.setPoint(line,7,0);
  126. delay(50);}
  127. for(colume = 6; colume >= 0; colume--){
  128. LED_Matrix.setPoint(7,colume,1);
  129. delay(50);}
  130. for(line = 6; line >= 1;line--);{
  131. LED_Matrix.setPoint(line,0,0);
  132. delay(50);}//0
  133. for(colume = 1; colume < 7; colume++){
  134. LED_Matrix.setPoint(1,colume,1);
  135. delay(50);
  136. }
  137. for(line = 3; line < 7;line++);
  138. {LED_Matrix.setPoint(line,6,1);
  139. delay(50);}
  140. for(colume = 5; colume >= 2; colume--){
  141. LED_Matrix.setPoint(6,colume,1);
  142. delay(50);}
  143. for(line = 5; line >= 2;line--);
  144. {LED_Matrix.setPoint(line,1,1);
  145. delay(50);}//1
  146. for(colume = 2; colume < 6; colume++){
  147. LED_Matrix.setPoint(2,colume,1);
  148. delay(50);
  149. }
  150. for(line = 4; line < 6;line++);
  151. {LED_Matrix.setPoint(line,5,1);
  152. delay(50);}
  153. for(colume = 5; colume >= 3; colume--){
  154. LED_Matrix.setPoint(5,colume,1);
  155. delay(50);}
  156. for(line = 4; line >= 3;line--);
  157. {LED_Matrix.setPoint(line,2,1);
  158. delay(50);}//2
  159. for(colume = 3; colume < 5; colume++){
  160. LED_Matrix.setPoint(3,colume,1);
  161. delay(50);
  162. }
  163. for(line = 3; line < 5;line++);
  164. {LED_Matrix.setPoint(line,4,1);
  165. delay(50);}
  166. for(colume = 4; colume >= 4; colume--){
  167. LED_Matrix.setPoint(4,colume,1);
  168. delay(50);}
  169. for(line = 3; line >= 3;line--);
  170. {LED_Matrix.setPoint(line,3,1);
  171. delay(50);}//3
  172. }
  173. //this is left for you to implement
  174. void displayZigZag()
  175. {
  176. }