Advertisement
RuiViana

Painel_Colorido

Oct 27th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.56 KB | None | 0 0
  1. /*---------------------------------------------
  2. S H I F T O U T M E G A
  3. Ampliar o número de saídas do Arduino com
  4. Registrador de Deslocamento 74HC595
  5. Fellipe Couto - 17/09/2012
  6. --------------------------------------------*/
  7. /*¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
  8. - Pino 2 do Arduino ligado ao pino 12 do CI.
  9. - Pino 3 do Arduino ligado ao pino 14 do CI.
  10. - Pino 4 do Arduino ligado ao pino 11 do CI.
  11. - Pinos 10 e 16 do CI ligados ao Vcc.
  12. - Pinos 8 e 13 do CI ligados ao GND.
  13. - Pino 9 do CI ligado ao pino 14 do próximo CI.
  14. ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
  15. #include <ShiftOutMega.h> //Inclui a bilioteca ShiftOutMega.h
  16.  
  17. //Variáveis do CI 74HC595 GRADAIVO-1
  18. int latchPin = 2;
  19. int dataPin = 3;
  20. int clockPin = 4;
  21. int qtdRegistradores = 3; //Quantidade de registradores(74HC595) utilizado no pro jeto.
  22. ShiftOutMega mega1(latchPin, dataPin, clockPin, qtdRegistradores); //Inicia a biblioteca passando os parametros de uso.
  23.  
  24. // ------------------------ Função Acende VD1 e apaga um a um
  25. void painelVD1 ()
  26. {
  27. //1º Painel VERDE
  28. mega1.shiftWrite(1, HIGH); //Ligando painel verde 1
  29. mega1.shiftWrite(2, HIGH);
  30. mega1.shiftWrite(3, HIGH);
  31. mega1.shiftWrite(4, HIGH);
  32. mega1.shiftWrite(5, HIGH);
  33. mega1.shiftWrite(6, HIGH);
  34. mega1.shiftWrite(7, HIGH);
  35. mega1.shiftWrite(8, HIGH);
  36. mega1.shiftWrite(9, HIGH);
  37. mega1.shiftWrite(10, HIGH);
  38. delay(1000);
  39.  
  40. mega1.shiftWrite(1, LOW); //Desligando painel verde 1
  41. delay(1000);
  42. mega1.shiftWrite(2, LOW);
  43. delay(1000);
  44. mega1.shiftWrite(3, LOW);
  45. delay(1000);
  46. mega1.shiftWrite(4, LOW);
  47. delay(1000);
  48. mega1.shiftWrite(5, LOW);
  49. delay(1000);
  50. mega1.shiftWrite(6, LOW);
  51. delay(1000);
  52. mega1.shiftWrite(7, LOW);
  53. delay(1000);
  54. mega1.shiftWrite(8, LOW);
  55. delay(1000);
  56. mega1.shiftWrite(9, LOW);
  57. delay(1000);
  58. mega1.shiftWrite(10, LOW);
  59. delay(1000);
  60. }
  61. // ------------------------ Função Acende VM1 e apaga um a um
  62. void painelVM1 () {
  63. //1º Painel VERMELHO
  64. mega1.shiftWrite(11, HIGH); //Ligando painel vermelho 1
  65. mega1.shiftWrite(12, HIGH);
  66. mega1.shiftWrite(13, HIGH);
  67. mega1.shiftWrite(14, HIGH);
  68. mega1.shiftWrite(15, HIGH);
  69. mega1.shiftWrite(16, HIGH);
  70. mega1.shiftWrite(17, HIGH);
  71. mega1.shiftWrite(18, HIGH);
  72. mega1.shiftWrite(19, HIGH);
  73. mega1.shiftWrite(20, HIGH);
  74.  
  75. delay(1000);
  76.  
  77. mega1.shiftWrite(11, LOW); //Desligando painel vermelho 1
  78. delay(1000);
  79. mega1.shiftWrite(12, LOW);
  80. delay(1000);
  81. mega1.shiftWrite(13, LOW);
  82. delay(1000);
  83. mega1.shiftWrite(14, LOW);
  84. delay(1000);
  85. mega1.shiftWrite(15, LOW);
  86. delay(1000);
  87. mega1.shiftWrite(16, LOW);
  88. delay(1000);
  89. mega1.shiftWrite(17, LOW);
  90. delay(1000);
  91. mega1.shiftWrite(18, LOW);
  92. delay(1000);
  93. mega1.shiftWrite(19, LOW);
  94. delay(1000);
  95. mega1.shiftWrite(20, LOW);
  96. delay(1000);
  97. }
  98. // ------------------------ Função Acende VD2 e apaga um a um
  99. void painelVD2 ()
  100. {
  101. //2º Painel VERDE
  102. mega1.shiftWrite(25, HIGH); //Ligando painel verde 2
  103. mega1.shiftWrite(26, HIGH);
  104. mega1.shiftWrite(27, HIGH);
  105. mega1.shiftWrite(28, HIGH);
  106. mega1.shiftWrite(29, HIGH);
  107. mega1.shiftWrite(30, HIGH);
  108. mega1.shiftWrite(31, HIGH);
  109. mega1.shiftWrite(32, HIGH);
  110. mega1.shiftWrite(33, HIGH);
  111. mega1.shiftWrite(34, HIGH);
  112. delay(1000);
  113.  
  114. mega1.shiftWrite(25, LOW); //Desligando painel verde 2
  115. delay(1000);
  116. mega1.shiftWrite(26, LOW);
  117. delay(1000);
  118. mega1.shiftWrite(27, LOW);
  119. delay(1000);
  120. mega1.shiftWrite(28, LOW);
  121. delay(1000);
  122. mega1.shiftWrite(29, LOW);
  123. delay(1000);
  124. mega1.shiftWrite(30, LOW);
  125. delay(1000);
  126. mega1.shiftWrite(31, LOW);
  127. delay(1000);
  128. mega1.shiftWrite(32, LOW);
  129. delay(1000);
  130. mega1.shiftWrite(33, LOW);
  131. delay(1000);
  132. mega1.shiftWrite(34, LOW);
  133. delay(1000);
  134. }
  135. // ------------------------ Função Acende VM2 e apaga um a um
  136. void painelVM2 ()
  137. {
  138. //2º Painel VERMELHO
  139. mega1.shiftWrite(35, HIGH); //Ligando painel vermelho 2
  140. mega1.shiftWrite(36, HIGH);
  141. mega1.shiftWrite(37, HIGH);
  142. mega1.shiftWrite(38, HIGH);
  143. mega1.shiftWrite(39, HIGH);
  144. mega1.shiftWrite(40, HIGH);
  145. mega1.shiftWrite(41, HIGH);
  146. mega1.shiftWrite(42, HIGH);
  147. mega1.shiftWrite(43, HIGH);
  148. mega1.shiftWrite(44, HIGH);
  149. delay(1000);
  150.  
  151. mega1.shiftWrite(35, LOW); //Desligando painel vermelho 2
  152. delay(1000);
  153. mega1.shiftWrite(36, LOW);
  154. delay(1000);
  155. mega1.shiftWrite(37, LOW);
  156. delay(1000);
  157. mega1.shiftWrite(38, LOW);
  158. delay(1000);
  159. mega1.shiftWrite(39, LOW);
  160. delay(1000);
  161. mega1.shiftWrite(40, LOW);
  162. delay(1000);
  163. mega1.shiftWrite(41, LOW);
  164. delay(1000);
  165. mega1.shiftWrite(42, LOW);
  166. delay(1000);
  167. mega1.shiftWrite(43, LOW);
  168. delay(1000);
  169. mega1.shiftWrite(44, LOW);
  170. delay(1000);
  171. }
  172. // ------------------------ Função Acende VD1 e VM2 e apaga um a um
  173. void painelVD1eVM2 ()
  174. {
  175. //1º Painel VERDE
  176. mega1.shiftWrite(1, HIGH); // LIGANDO Painel verde 1
  177. mega1.shiftWrite(2, HIGH);
  178. mega1.shiftWrite(3, HIGH);
  179. mega1.shiftWrite(4, HIGH);
  180. mega1.shiftWrite(5, HIGH);
  181. mega1.shiftWrite(6, HIGH);
  182. mega1.shiftWrite(7, HIGH);
  183. mega1.shiftWrite(8, HIGH);
  184. mega1.shiftWrite(9, HIGH);
  185. mega1.shiftWrite(10, HIGH);
  186.  
  187. mega1.shiftWrite(35, HIGH); //LIGANDO Painel vermelho 2
  188. mega1.shiftWrite(36, HIGH);
  189. mega1.shiftWrite(37, HIGH);
  190. mega1.shiftWrite(38, HIGH);
  191. mega1.shiftWrite(39, HIGH);
  192. mega1.shiftWrite(40, HIGH);
  193. mega1.shiftWrite(41, HIGH);
  194. mega1.shiftWrite(42, HIGH);
  195. mega1.shiftWrite(43, HIGH);
  196. mega1.shiftWrite(44, HIGH);
  197. delay(1000);
  198. //ATÉ AQUI FUNCIONA NOEMAL
  199.  
  200. //ERRO NA PARTE ABAIXO!!! a parte que inicia DESLIGAR da os dois grupos de LED, um a um, faz é LIGAR o VERDE e VERMELHO em todos LED, para depois ir DESLIGANDO
  201. mega1.shiftWrite(1, LOW); //DESLIGANDO Painel verde
  202. mega1.shiftWrite(35, LOW); //DESLIGANDO Painel vermelho 2
  203. delay(1000);
  204. mega1.shiftWrite(2, LOW);
  205. mega1.shiftWrite(36, LOW);
  206. delay(1000);
  207. mega1.shiftWrite(3, LOW);
  208. mega1.shiftWrite(37, LOW);
  209. delay(1000);
  210. mega1.shiftWrite(4, LOW);
  211. mega1.shiftWrite(38, LOW);
  212. delay(1000);
  213. mega1.shiftWrite(5, LOW);
  214. mega1.shiftWrite(39, LOW);
  215. delay(1000);
  216. mega1.shiftWrite(6, LOW);
  217. mega1.shiftWrite(40, LOW);
  218. delay(1000);
  219. mega1.shiftWrite(7, LOW);
  220. mega1.shiftWrite(41, LOW);
  221. delay(1000);
  222. mega1.shiftWrite(8, LOW);
  223. mega1.shiftWrite(42, LOW);
  224. delay(1000);
  225. mega1.shiftWrite(9, LOW);
  226. mega1.shiftWrite(43, LOW);
  227. delay(1000);
  228. mega1.shiftWrite(10, LOW);
  229. mega1.shiftWrite(44, LOW);
  230. delay(1000);
  231. }
  232. // ------------------------ Função Acende VM1 e VD2 e apaga um a um
  233.  
  234. //FUNCIONA NORMAL A PARTE ABAIXO PARA LIGAR OS DOIS GRUPOS DE LED
  235.  
  236. void painelVD2eVM1 ()
  237. {
  238. //2º Painel VERDE
  239. mega1.shiftWrite(25, HIGH); //DESLIGAR painel verde 2
  240. mega1.shiftWrite(26, HIGH);
  241. mega1.shiftWrite(27, HIGH);
  242. mega1.shiftWrite(28, HIGH);
  243. mega1.shiftWrite(29, HIGH);
  244. mega1.shiftWrite(30, HIGH);
  245. mega1.shiftWrite(31, HIGH);
  246. mega1.shiftWrite(32, HIGH);
  247. mega1.shiftWrite(33, HIGH);
  248. mega1.shiftWrite(34, HIGH);
  249.  
  250. mega1.shiftWrite(11, HIGH); //LIGANDO painel vermelho 1
  251. mega1.shiftWrite(12, HIGH);
  252. mega1.shiftWrite(13, HIGH);
  253. mega1.shiftWrite(14, HIGH);
  254. mega1.shiftWrite(15, HIGH);
  255. mega1.shiftWrite(16, HIGH);
  256. mega1.shiftWrite(17, HIGH);
  257. mega1.shiftWrite(18, HIGH);
  258. mega1.shiftWrite(19, HIGH);
  259. mega1.shiftWrite(20, HIGH);
  260. delay(1000);
  261.  
  262. //ERRO NA PARTE ABAIXO, a parte que inicia DESLIGAR da os dois grupos de LED, um a um, faz é LIGAR o VERDE e VERMELHO em todos LED, para depois ir DESLIGANDO
  263.  
  264. mega1.shiftWrite(25, LOW); //DESLIGAR painel verde 2
  265. mega1.shiftWrite(11, LOW); //DESLIGAR painel vermelho 1
  266. delay(1000);
  267. mega1.shiftWrite(26, LOW);
  268. mega1.shiftWrite(12, LOW);
  269. delay(1000);
  270. mega1.shiftWrite(27, LOW);
  271. mega1.shiftWrite(13, LOW);
  272. delay(1000);
  273. mega1.shiftWrite(28, LOW);
  274. mega1.shiftWrite(14, LOW);
  275. delay(1000);
  276. mega1.shiftWrite(29, LOW);
  277. mega1.shiftWrite(15, LOW);
  278. delay(1000);
  279. mega1.shiftWrite(30, LOW);
  280. mega1.shiftWrite(16, LOW);
  281. delay(1000);
  282. mega1.shiftWrite(31, LOW);
  283. mega1.shiftWrite(17, LOW);
  284. delay(1000);
  285. mega1.shiftWrite(32, LOW);
  286. mega1.shiftWrite(18, LOW);
  287. delay(1000);
  288. mega1.shiftWrite(33, LOW);
  289. mega1.shiftWrite(19, LOW);
  290. delay(1000);
  291. mega1.shiftWrite(34, LOW);
  292. mega1.shiftWrite(20, LOW);
  293. delay(1000);
  294. }
  295. void setup()
  296. {
  297. }
  298. void loop()
  299. {
  300. painelVD1 ();
  301. painelVM1 ();
  302. painelVD2 ();
  303. painelVM2 ();
  304. painelVD1eVM2 ();
  305. painelVD2eVM1 ();
  306. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement