极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 107691|回复: 33

【Z】Arduino直驱4阶光立方~打造最快速制作的光立方~

[复制链接]
发表于 2013-6-17 12:59:31 | 显示全部楼层 |阅读模式
嗯,Z最近感觉想做很多东西,昨天心血来潮,决定做一个光立方。但是大家都知道,8阶的主流光立方,驱动比较复杂,耗时相当的长,所以今天就有这么一个CUBE4光立方的教程~来让大家都可以很快的做出很好看的光立方~

首先是在纸盒上打好每一层的格子,然后把LED的阴极折弯,每一层的阴极全部焊接在一起,每一层的阳极全部竖起~:


一共要做4组,共64个LED


之后把每一层的16个阳极和下一层的16个阳极分别焊接起来~并且每一层的阴极针脚留出来~


最后把板子钻个洞,把每一层得到阴极引脚用导线焊接出来,从洞中穿过去~如图~


因为普通的光立方的发光立方体和驱动板是焊死的,所以这次我们改变方案,将整个发光体做成一个小模块,这样即方便,又美观~还方便更换~

看到了么~16的阳极引脚全部用导线引到另一张洞洞板上,连在长排针上~(重点,长排针)


然后就是控制板的焊接,控制板很好做,只要将4个阴极和16个阳极分别加上安全电阻连接到arduino的20个针脚上,硬件部分就大功告成了!~


程序采用的是老外CUBE4的驱动程序,很不错~而且所显示的动画可以在线制作~

程序代码:
  1. #include <avr/pgmspace.h> // allows use of PROGMEM to store patterns in flash

  2. #define CUBESIZE 4
  3. #define PLANESIZE CUBESIZE*CUBESIZE
  4. #define PLANETIME 3333 // time each plane is displayed in us -> 100 Hz refresh
  5. #define TIMECONST 20 // multiplies DisplayTime to get ms - why not =100?

  6. // LED Pattern Table in PROGMEM - last column is display time in 100ms units
  7. // TODO this could be a lot more compact but not with binary pattern representation
  8. prog_uchar PROGMEM PatternTable[] = {
  9. // blink on and off

  10. B0001,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  11. B0011,B0000,B0000,B0000,B0011,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  12. B0011,B0010,B0000,B0000,B0011,B0010,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  13. B0011,B0011,B0000,B0000,B0011,B0011,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  14. B0110,B0110,B0000,B0000,B0110,B0110,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  15. B0000,B0000,B0000,B0000,B0110,B0110,B0000,B0000,B0110,B0110,B0000,B0000,B0000,B0000,B0000,B0000,10,
  16. B0000,B0000,B0000,B0000,B0000,B0110,B0110,B0000,B0000,B0110,B0110,B0000,B0000,B0000,B0000,B0000,10,
  17. B0000,B0000,B0000,B0000,B0000,B0000,B0110,B0110,B0000,B0000,B0110,B0110,B0000,B0000,B0000,B0000,10,
  18. B0000,B0000,B0000,B0000,B0000,B0000,B0011,B0011,B0000,B0000,B0011,B0011,B0000,B0000,B0000,B0000,10,
  19. B0000,B0000,B0000,B0000,B0000,B0001,B0011,B0111,B0000,B0001,B0011,B0111,B0000,B0000,B0001,B0011,10,
  20. B0000,B0000,B0000,B0000,B0000,B0011,B0111,B0111,B0000,B0011,B0111,B0111,B0000,B0001,B0011,B0111,10,
  21. B0000,B0000,B0000,B0000,B0000,B0111,B0111,B0111,B0000,B0111,B0111,B0111,B0000,B0011,B0111,B0111,10,
  22. B0000,B0000,B0000,B0000,B0000,B0111,B0111,B0111,B0000,B0111,B0111,B0111,B0000,B0111,B0111,B0111,10,
  23. B0000,B0000,B0000,B0000,B0000,B1110,B1110,B1110,B0000,B1110,B1110,B1110,B0000,B1110,B1110,B1110,10,
  24. B0000,B1110,B1110,B1110,B0000,B1110,B1110,B1110,B0000,B1110,B1110,B1110,B0000,B0000,B0000,B0000,10,
  25. B0000,B1110,B1110,B1110,B0000,B1110,B1110,B1110,B0000,B1100,B1110,B1110,B0000,B0000,B0000,B0000,10,
  26. B0000,B1110,B1110,B1110,B0000,B1100,B1110,B1110,B0000,B1000,B1100,B1110,B0000,B0000,B0000,B0000,10,
  27. B0000,B1100,B1110,B1110,B0000,B1000,B1100,B1110,B0000,B0000,B1000,B1100,B0000,B0000,B0000,B0000,10,
  28. B0000,B1000,B1100,B1110,B0000,B0000,B1000,B1100,B0000,B0000,B0000,B1000,B0000,B0000,B0000,B0000,10,
  29. B0000,B0000,B1000,B1100,B0000,B0000,B0000,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  30. B0000,B0000,B0000,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  31. B0000,B0000,B1000,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  32. B0000,B1000,B1000,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  33. B1000,B1000,B1000,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  34. B1100,B1000,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  35. B1110,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  36. B1110,B0000,B0000,B0000,B0010,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  37. B0110,B0000,B0000,B0000,B0011,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  38. B0010,B0000,B0000,B0000,B0011,B0001,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  39. B0000,B0000,B0000,B0000,B0011,B0001,B0001,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  40. B0000,B0000,B0000,B0000,B0001,B0001,B0001,B0001,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  41. B0000,B0000,B0000,B0000,B0000,B0001,B0001,B0011,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  42. B0000,B0000,B0000,B0000,B0000,B0000,B0001,B0111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  43. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  44. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1110,B0000,B0000,B0000,B1000,B0000,B0000,B0000,B0000,10,
  45. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1100,B0000,B0000,B1000,B1000,B0000,B0000,B0000,B0000,10,
  46. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1000,B0000,B0000,B1100,B1000,B0000,B0000,B0000,B0000,10,
  47. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1110,B1000,B0000,B0000,B0000,B0000,10,
  48. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,B0000,B0000,10,
  49. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0001,B0111,B0000,B0000,B0000,B0000,B0000,10,
  50. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0001,B0001,B0011,B0000,B0000,B0000,B0000,B0000,10,
  51. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0001,B0001,B0001,B0000,B0001,B0000,B0000,B0000,10,
  52. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0001,B0001,B0000,B0000,B0011,B0000,B0000,B0000,10,
  53. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0111,B0000,B0000,B0000,10,
  54. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1111,B0000,B0000,B0000,10,
  55. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1110,B1000,B0000,B0000,10,
  56. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1100,B1100,B0000,B0000,10,
  57. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1000,B1110,B0000,B0000,10,
  58. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1111,B0000,B0000,10,
  59. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0111,B0000,B0000,10,
  60. B0000,B0000,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0011,B0000,B0000,10,
  61. B0000,B0001,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0001,B0000,B0000,10,
  62. B0001,B0001,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0000,B0000,B0000,10,
  63. B0011,B0001,B0000,B0000,B0000,B0001,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  64. B0111,B0001,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  65. B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  66. B1111,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  67. B1111,B1100,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  68. B1111,B1110,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  69. B1111,B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  70. B1111,B1111,B0001,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  71. B1111,B1111,B0011,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  72. B1111,B1111,B0111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  73. B1111,B1111,B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  74. B1111,B1111,B1111,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  75. B1111,B1111,B1111,B1100,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  76. B1111,B1111,B1111,B1110,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  77. B1111,B1111,B1111,B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  78. B1111,B1111,B1111,B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  79. B0111,B0111,B0111,B0111,B1000,B1000,B1000,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  80. B0011,B0011,B0011,B0011,B0100,B0100,B0100,B0100,B1000,B1000,B1000,B1000,B0000,B0000,B0000,B0000,10,
  81. B0001,B0001,B0001,B0001,B0010,B0010,B0010,B0010,B0100,B0100,B0100,B0100,B1000,B1000,B1000,B1000,10,
  82. B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0010,B0010,B0010,B0010,B0100,B0100,B0100,B0100,10,
  83. B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0010,B0010,B0010,B0010,10,
  84. B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,B0001,10,
  85. B0010,B0001,B0001,B0001,B0010,B0001,B0001,B0001,B0010,B0001,B0001,B0001,B0010,B0001,B0001,B0001,10,
  86. B0100,B0010,B0001,B0001,B0100,B0010,B0001,B0001,B0100,B0010,B0001,B0001,B0100,B0010,B0001,B0001,10,
  87. B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
  88. B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
  89. B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
  90. B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
  91. B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,10,
  92. B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,10,
  93. B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
  94. B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
  95. B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
  96. B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
  97. B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
  98. B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
  99. B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
  100. B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
  101. B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,10,
  102. B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,10,
  103. B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
  104. B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
  105. B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
  106. B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
  107. B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
  108. B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
  109. B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
  110. B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
  111. B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,10,
  112. B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,10,
  113. B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
  114. B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
  115. B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
  116. B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
  117. B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
  118. B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
  119. B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
  120. B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
  121. B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,10,
  122. B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,10,
  123. B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
  124. B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
  125. B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
  126. B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
  127. B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
  128. B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
  129. B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
  130. B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
  131. B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,10,
  132. B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,10,
  133. B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
  134. B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
  135. B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
  136. B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
  137. B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
  138. B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
  139. B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
  140. B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
  141. B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,10,
  142. B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,B0100,B0100,B0010,B0010,10,
  143. B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001,10,
  144. B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,B0000,B1100,B0011,B0000,10,
  145. B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,B0000,B0011,B1100,B0000,10,
  146. B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
  147. B0000,B0010,B0100,B0000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
  148. B0000,B0000,B0000,B0000,B0000,B0010,B0100,B0000,B0001,B0010,B0100,B1000,B0001,B0010,B0100,B1000,10,
  149. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0010,B0100,B0000,B0001,B0010,B0100,B1000,10,
  150. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0010,B0100,B0000,10,
  151. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  152. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1000,10,
  153. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1000,B0000,B0010,B0000,B1000,10,
  154. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B1000,B0000,B0010,B0000,B1000,B0000,B0010,B1000,B0000,10,
  155. B0000,B0000,B0000,B1000,B0000,B0010,B0000,B1000,B0000,B0010,B1000,B0000,B0000,B0000,B1000,B0000,10,
  156. B0000,B0010,B0000,B1000,B0000,B0010,B1000,B0000,B0000,B0000,B1000,B0000,B0000,B0000,B0000,B0000,10,
  157. B0000,B0010,B1000,B0000,B0000,B0000,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  158. B0000,B0000,B1000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  159. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  160. B0000,B0100,B0010,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  161. B0000,B0110,B0110,B0000,B0000,B0100,B0010,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  162. B1001,B0110,B0110,B1001,B0000,B0110,B0110,B0000,B0000,B0100,B0010,B0000,B0000,B0000,B0000,B0000,10,
  163. B1101,B0111,B1110,B1011,B1001,B0110,B0110,B1001,B0000,B0110,B0110,B0000,B0000,B0100,B0010,B0000,10,
  164. B1111,B1111,B1111,B1111,B1101,B0111,B1110,B1011,B1001,B0110,B0110,B1001,B0000,B0110,B0110,B0000,10,
  165. B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1101,B0111,B1110,B1011,B1001,B0110,B0110,B1001,10,
  166. B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1101,B0111,B1110,B1011,10,
  167. B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,10,
  168. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  169. B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,10,
  170. B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B0000,B0000,B0000,B0000,10,
  171. B1111,B1111,B1111,B1111,B1111,B1111,B1111,B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  172. B1111,B1111,B1111,B1111,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,
  173. B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,B0000,10,


  174. // this is a dummy element for end of table (duration=0) aka !!!DO NOT TOUCH!!!
  175. B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, B0000, 0
  176. };

  177. /*
  178. ** Defining pins in array makes it easier to rearrange how cube is wired
  179. ** Adjust numbers here until LEDs flash in order - L to R, T to B
  180. ** Note that analog inputs 0-5 are also digital outputs 14-19!
  181. ** Pin DigitalOut0 (serial RX) and AnalogIn5 are left open for future apps
  182. */

  183. int LEDPin[] = { 2, 3, 4, 5, 6, 7, 8, 9,10,11, 12,13, 14,15,16,17};
  184. int PlanePin[] = {A4,A5,0,1};

  185. // initialization
  186. void setup()
  187. {
  188. int pin; // loop counter
  189. // set up LED pins as output (active HIGH)
  190. for (pin=0; pin<PLANESIZE; pin++) {
  191. pinMode( LEDPin[pin], OUTPUT );
  192. }
  193. // set up plane pins as outputs (active LOW)
  194. for (pin=0; pin<CUBESIZE; pin++) {
  195. pinMode( PlanePin[pin], OUTPUT );
  196. }
  197. }

  198. // display pattern in table until DisplayTime is zero (then repeat)
  199. void loop()
  200. {
  201. // declare variables
  202. byte PatternBuf[PLANESIZE]; // saves current pattern from PatternTable
  203. int PatternIdx;
  204. byte DisplayTime; // time*100ms to display pattern
  205. unsigned long EndTime;
  206. int plane; // loop counter for cube refresh
  207. int patbufidx; // indexes which byte from pattern buffer
  208. int ledrow; // counts LEDs in refresh loop
  209. int ledcol; // counts LEDs in refresh loop
  210. int ledpin; // counts LEDs in refresh loop

  211. // Initialize PatternIdx to beginning of pattern table
  212. PatternIdx = 0;
  213. // loop over entries in pattern table - while DisplayTime>0
  214. do {
  215. // read pattern from PROGMEM and save in array
  216. memcpy_P( PatternBuf, PatternTable+PatternIdx, PLANESIZE );
  217. PatternIdx += PLANESIZE;
  218. // read DisplayTime from PROGMEM and increment index
  219. DisplayTime = pgm_read_byte_near( PatternTable + PatternIdx++ );
  220. // compute EndTime from current time (ms) and DisplayTime
  221. EndTime = millis() + ((unsigned long) DisplayTime) * TIMECONST;

  222. // loop while DisplayTime>0 and current time < EndTime
  223. while ( millis() < EndTime ) {
  224. patbufidx = 0; // reset index counter to beginning of buffer
  225. // loop over planes
  226. for (plane=0; plane<CUBESIZE; plane++) {
  227. // turn previous plane off
  228. if (plane==0) {
  229. digitalWrite( PlanePin[CUBESIZE-1], HIGH );
  230. } else {
  231. digitalWrite( PlanePin[plane-1], HIGH );
  232. }

  233. // load current plane pattern data into ports
  234. ledpin = 0;
  235. for (ledrow=0; ledrow<CUBESIZE; ledrow++) {
  236. for (ledcol=0; ledcol<CUBESIZE; ledcol++) {
  237. digitalWrite( LEDPin[ledpin++], PatternBuf[patbufidx] & (1 << ledcol) );
  238. }
  239. patbufidx++;
  240. }

  241. // turn current plane on
  242. digitalWrite( PlanePin[plane], LOW );
  243. // delay PLANETIME us
  244. delayMicroseconds( PLANETIME );
  245. } // for plane
  246. } // while <EndTime
  247. } while (DisplayTime > 0); // read patterns until time=0 which signals end
  248. }
复制代码


最终的完成图~






视频~

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

评分

参与人数 1 +1 收起 理由
幻生幻灭 + 1 赞一个!

查看全部评分

回复

使用道具 举报

发表于 2013-10-20 17:27:39 | 显示全部楼层
硬件方面:LED的负极统一都接GND么,还是有其他要求?
回复 支持 1 反对 0

使用道具 举报

发表于 2013-6-17 13:10:06 | 显示全部楼层
沙发~
回复 支持 反对

使用道具 举报

发表于 2013-6-17 13:17:39 | 显示全部楼层
貌似牛
回复 支持 反对

使用道具 举报

发表于 2013-6-17 13:18:12 | 显示全部楼层
不错,前来帮顶
回复 支持 反对

使用道具 举报

发表于 2013-6-17 17:59:51 | 显示全部楼层
还是不明白和杜洋做的那个有啥区别
回复 支持 反对

使用道具 举报

发表于 2013-6-17 20:47:02 | 显示全部楼层
学慧放弃 发表于 2013-6-17 17:59
还是不明白和杜洋做的那个有啥区别

上次焊那光立方的灯累死人,做那没啥意思,浪费时间
回复 支持 反对

使用道具 举报

发表于 2013-6-17 21:01:34 | 显示全部楼层
很好的东西。

只是有个问题。

Arduino UNO 数字端口只有13个。

该如何接?

如果能接程序该如何改呢?
回复 支持 反对

使用道具 举报

发表于 2013-6-17 23:28:27 | 显示全部楼层
tom 发表于 2013-6-17 21:01
很好的东西。

只是有个问题。

模拟口也可以作数字口使用的~
楼主这个需要16+4个I/O口就可以了~
回复 支持 反对

使用道具 举报

发表于 2013-6-18 12:11:35 | 显示全部楼层
谢谢楼主分享
回复 支持 反对

使用道具 举报

发表于 2013-6-18 14:21:05 | 显示全部楼层
  学习了,做的真好
回复 支持 反对

使用道具 举报

发表于 2013-6-18 15:58:35 来自手机 | 显示全部楼层
模拟口可以做为输出么?
回复 支持 反对

使用道具 举报

发表于 2013-6-25 19:10:44 | 显示全部楼层
我也做了一个。
使用Mango控制器。
由于针脚不够,用了模拟口
程序修改为int LEDPin[] = { 2, 3, 4, 5, 6, 7, 8, 9,10,11, 12,13,A0,A1,A2,A3};
int PlanePin[] = {A4,A5,0,1};
每个针脚都连接了一个1K电阻

运行程序发现第三层LED不亮。

用5V电压加一个1K电阻,测试第三层LED,LED能点亮。

问题出在哪呢?
回复 支持 反对

使用道具 举报

发表于 2013-9-28 16:46:33 | 显示全部楼层
谢谢分享…………
回复 支持 反对

使用道具 举报

发表于 2013-10-2 20:22:49 | 显示全部楼层
求电路图。给个电路图吧
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-18 12:53 , Processed in 0.062257 second(s), 33 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表