Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. #define rows 7
  2. #define rows_offset 2
  3. #define cols 5
  4. #define cols_offset 9
  5. #define blue 11
  6.  
  7. const int lowestPin = 0;
  8. const int highestPin = 13;
  9. int steps = 0;
  10.  
  11.  
  12. int Matrix[6][rows][cols] = {
  13. {
  14. {0, 1, 1, 1, 0},
  15. {1, 0, 0, 0, 1},
  16. {1, 0, 0, 0, 0},
  17. {0, 1, 1, 1, 0},
  18. {0, 0, 0, 0, 1},
  19. {1, 0, 0, 0, 1},
  20. {0, 1, 1, 1, 0},
  21. },
  22. {
  23. {1, 1, 1, 1, 0},
  24. {1, 0, 0, 0, 1},
  25. {1, 0, 0, 0, 1},
  26. {1, 1, 1, 1, 0},
  27. {1, 0, 0, 0, 0},
  28. {1, 0, 0, 0, 0},
  29. {1, 0, 0, 0, 0},
  30. },
  31. {
  32. {0, 1, 1, 1, 0},
  33. {1, 0, 0, 0, 1},
  34. {1, 0, 0, 0, 0},
  35. {0, 1, 1, 1, 0},
  36. {0, 0, 0, 0, 1},
  37. {1, 0, 0, 0, 1},
  38. {0, 1, 1, 1, 0},
  39. },
  40. {
  41. {1, 1, 1, 1, 1},
  42. {1, 0, 0, 0, 0},
  43. {1, 0, 0, 0, 0},
  44. {1, 1, 1, 1, 0},
  45. {1, 0, 0, 0, 0},
  46. {1, 0, 0, 0, 0},
  47. {1, 1, 1, 1, 1},
  48. },
  49. {
  50. {1, 0, 0, 0, 1},
  51. {1, 0, 0, 1, 0},
  52. {1, 0, 1, 0, 0},
  53. {1, 1, 0, 0, 0},
  54. {1, 0, 1, 0, 0},
  55. {1, 0, 0, 1, 0},
  56. {1, 0, 0, 0, 1},
  57. },
  58. {
  59. {1, 1, 1, 1, 1},
  60. {1, 0, 0, 0, 0},
  61. {1, 0, 0, 0, 0},
  62. {1, 1, 1, 1, 0},
  63. {1, 0, 0, 0, 0},
  64. {1, 0, 0, 0, 0},
  65. {1, 1, 1, 1, 1},
  66. }
  67. };
  68.  
  69. int MatrixS[rows][cols] = {
  70. {0, 1, 1, 1, 0},
  71. {1, 0, 0, 0, 1},
  72. {1, 0, 0, 0, 0},
  73. {0, 1, 1, 1, 0},
  74. {0, 0, 0, 0, 1},
  75. {1, 0, 0, 0, 1},
  76. {0, 1, 1, 1, 0},
  77. };
  78. int MatrixP[rows][cols] = {
  79. {1, 1, 1, 1, 0},
  80. {1, 0, 0, 0, 1},
  81. {1, 0, 0, 0, 1},
  82. {1, 1, 1, 1, 0},
  83. {1, 0, 0, 0, 0},
  84. {1, 0, 0, 0, 0},
  85. {1, 0, 0, 0, 0},
  86. };
  87. int MatrixE[rows][cols] = {
  88. {1, 1, 1, 1, 1},
  89. {1, 0, 0, 0, 0},
  90. {1, 0, 0, 0, 0},
  91. {1, 1, 1, 1, 0},
  92. {1, 0, 0, 0, 0},
  93. {1, 0, 0, 0, 0},
  94. {1, 1, 1, 1, 1},
  95. };
  96. int MatrixK[rows][cols] = {
  97. {1, 0, 0, 0, 1},
  98. {1, 0, 0, 1, 0},
  99. {1, 0, 1, 0, 0},
  100. {1, 1, 0, 0, 0},
  101. {1, 0, 1, 0, 0},
  102. {1, 0, 0, 1, 0},
  103. {1, 0, 0, 0, 1},
  104. };
  105.  
  106. void setup() {
  107. for (int thisPin = lowestPin; thisPin <= highestPin; thisPin++) {
  108. pinMode(thisPin, OUTPUT);
  109. }
  110. }
  111.  
  112. void loop() {
  113. steps++;
  114. int c = (steps / 100) % 6;
  115. for (int row = 0; row < rows; row++) {
  116. digitalWrite(row + rows_offset, LOW);
  117. for (int col = 0; col < cols; col++) {
  118. digitalWrite(col + cols_offset, Matrix[c][row][col]);
  119. }
  120. delay(1);
  121. digitalWrite(row + rows_offset, HIGH);
  122. }
  123. /* for (int row = rows_offset; row < rows+rows_offset; row++ ) {
  124. digitalWrite(row, HIGH);
  125. for (int col = cols_offset; col < cols + cols_offset; col++) {
  126. digitalWrite(col, LOW);
  127. delay(200);
  128. }
  129. }*/
  130. /* for (int i = 8; i <= 13; i++) {
  131. digitalWrite(i, HIGH);
  132. }
  133. for (int i = 2; i < 9; i++) {
  134. digitalWrite(i, LOW);
  135. }
  136. delay(500);
  137. for (int i = 2; i < 9; i++) {
  138. digitalWrite(i, HIGH);
  139. }
  140. for (int i = 9; i <= 13; i++) {
  141. digitalWrite(i, LOW);
  142. }*/
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement