Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*---------------------------------------------
- S H I F T O U T M E G A
- Ampliar o número de saídas do Arduino com
- Registrador de Deslocamento 74HC595
- Fellipe Couto - 17/09/2012
- --------------------------------------------*/
- /*¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
- - Pino 2 do Arduino ligado ao pino 12 do CI.
- - Pino 3 do Arduino ligado ao pino 14 do CI.
- - Pino 4 do Arduino ligado ao pino 11 do CI.
- - Pinos 10 e 16 do CI ligados ao Vcc.
- - Pinos 8 e 13 do CI ligados ao GND.
- - Pino 9 do CI ligado ao pino 14 do próximo CI.
- ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨*/
- #include <ShiftOutMega.h> //Inclui a bilioteca ShiftOutMega.h
- //Variáveis do CI 74HC595 GRADAIVO-1
- int latchPin = 2;
- int dataPin = 3;
- int clockPin = 4;
- int qtdRegistradores = 3; //Quantidade de registradores(74HC595) utilizado no pro jeto.
- ShiftOutMega mega1(latchPin, dataPin, clockPin, qtdRegistradores); //Inicia a biblioteca passando os parametros de uso.
- // ------------------------ Função Acende VD1 e apaga um a um
- void painelVD1 ()
- {
- //1º Painel VERDE
- mega1.shiftWrite(1, HIGH); //Ligando painel verde 1
- mega1.shiftWrite(2, HIGH);
- mega1.shiftWrite(3, HIGH);
- mega1.shiftWrite(4, HIGH);
- mega1.shiftWrite(5, HIGH);
- mega1.shiftWrite(6, HIGH);
- mega1.shiftWrite(7, HIGH);
- mega1.shiftWrite(8, HIGH);
- mega1.shiftWrite(9, HIGH);
- mega1.shiftWrite(10, HIGH);
- delay(1000);
- mega1.shiftWrite(1, LOW); //Desligando painel verde 1
- delay(1000);
- mega1.shiftWrite(2, LOW);
- delay(1000);
- mega1.shiftWrite(3, LOW);
- delay(1000);
- mega1.shiftWrite(4, LOW);
- delay(1000);
- mega1.shiftWrite(5, LOW);
- delay(1000);
- mega1.shiftWrite(6, LOW);
- delay(1000);
- mega1.shiftWrite(7, LOW);
- delay(1000);
- mega1.shiftWrite(8, LOW);
- delay(1000);
- mega1.shiftWrite(9, LOW);
- delay(1000);
- mega1.shiftWrite(10, LOW);
- delay(1000);
- }
- // ------------------------ Função Acende VM1 e apaga um a um
- void painelVM1 () {
- //1º Painel VERMELHO
- mega1.shiftWrite(11, HIGH); //Ligando painel vermelho 1
- mega1.shiftWrite(12, HIGH);
- mega1.shiftWrite(13, HIGH);
- mega1.shiftWrite(14, HIGH);
- mega1.shiftWrite(15, HIGH);
- mega1.shiftWrite(16, HIGH);
- mega1.shiftWrite(17, HIGH);
- mega1.shiftWrite(18, HIGH);
- mega1.shiftWrite(19, HIGH);
- mega1.shiftWrite(20, HIGH);
- delay(1000);
- mega1.shiftWrite(11, LOW); //Desligando painel vermelho 1
- delay(1000);
- mega1.shiftWrite(12, LOW);
- delay(1000);
- mega1.shiftWrite(13, LOW);
- delay(1000);
- mega1.shiftWrite(14, LOW);
- delay(1000);
- mega1.shiftWrite(15, LOW);
- delay(1000);
- mega1.shiftWrite(16, LOW);
- delay(1000);
- mega1.shiftWrite(17, LOW);
- delay(1000);
- mega1.shiftWrite(18, LOW);
- delay(1000);
- mega1.shiftWrite(19, LOW);
- delay(1000);
- mega1.shiftWrite(20, LOW);
- delay(1000);
- }
- // ------------------------ Função Acende VD2 e apaga um a um
- void painelVD2 ()
- {
- //2º Painel VERDE
- mega1.shiftWrite(25, HIGH); //Ligando painel verde 2
- mega1.shiftWrite(26, HIGH);
- mega1.shiftWrite(27, HIGH);
- mega1.shiftWrite(28, HIGH);
- mega1.shiftWrite(29, HIGH);
- mega1.shiftWrite(30, HIGH);
- mega1.shiftWrite(31, HIGH);
- mega1.shiftWrite(32, HIGH);
- mega1.shiftWrite(33, HIGH);
- mega1.shiftWrite(34, HIGH);
- delay(1000);
- mega1.shiftWrite(25, LOW); //Desligando painel verde 2
- delay(1000);
- mega1.shiftWrite(26, LOW);
- delay(1000);
- mega1.shiftWrite(27, LOW);
- delay(1000);
- mega1.shiftWrite(28, LOW);
- delay(1000);
- mega1.shiftWrite(29, LOW);
- delay(1000);
- mega1.shiftWrite(30, LOW);
- delay(1000);
- mega1.shiftWrite(31, LOW);
- delay(1000);
- mega1.shiftWrite(32, LOW);
- delay(1000);
- mega1.shiftWrite(33, LOW);
- delay(1000);
- mega1.shiftWrite(34, LOW);
- delay(1000);
- }
- // ------------------------ Função Acende VM2 e apaga um a um
- void painelVM2 ()
- {
- //2º Painel VERMELHO
- mega1.shiftWrite(35, HIGH); //Ligando painel vermelho 2
- mega1.shiftWrite(36, HIGH);
- mega1.shiftWrite(37, HIGH);
- mega1.shiftWrite(38, HIGH);
- mega1.shiftWrite(39, HIGH);
- mega1.shiftWrite(40, HIGH);
- mega1.shiftWrite(41, HIGH);
- mega1.shiftWrite(42, HIGH);
- mega1.shiftWrite(43, HIGH);
- mega1.shiftWrite(44, HIGH);
- delay(1000);
- mega1.shiftWrite(35, LOW); //Desligando painel vermelho 2
- delay(1000);
- mega1.shiftWrite(36, LOW);
- delay(1000);
- mega1.shiftWrite(37, LOW);
- delay(1000);
- mega1.shiftWrite(38, LOW);
- delay(1000);
- mega1.shiftWrite(39, LOW);
- delay(1000);
- mega1.shiftWrite(40, LOW);
- delay(1000);
- mega1.shiftWrite(41, LOW);
- delay(1000);
- mega1.shiftWrite(42, LOW);
- delay(1000);
- mega1.shiftWrite(43, LOW);
- delay(1000);
- mega1.shiftWrite(44, LOW);
- delay(1000);
- }
- // ------------------------ Função Acende VD1 e VM2 e apaga um a um
- void painelVD1eVM2 ()
- {
- //1º Painel VERDE
- mega1.shiftWrite(1, HIGH); // LIGANDO Painel verde 1
- mega1.shiftWrite(2, HIGH);
- mega1.shiftWrite(3, HIGH);
- mega1.shiftWrite(4, HIGH);
- mega1.shiftWrite(5, HIGH);
- mega1.shiftWrite(6, HIGH);
- mega1.shiftWrite(7, HIGH);
- mega1.shiftWrite(8, HIGH);
- mega1.shiftWrite(9, HIGH);
- mega1.shiftWrite(10, HIGH);
- mega1.shiftWrite(35, HIGH); //LIGANDO Painel vermelho 2
- mega1.shiftWrite(36, HIGH);
- mega1.shiftWrite(37, HIGH);
- mega1.shiftWrite(38, HIGH);
- mega1.shiftWrite(39, HIGH);
- mega1.shiftWrite(40, HIGH);
- mega1.shiftWrite(41, HIGH);
- mega1.shiftWrite(42, HIGH);
- mega1.shiftWrite(43, HIGH);
- mega1.shiftWrite(44, HIGH);
- delay(1000);
- //ATÉ AQUI FUNCIONA NOEMAL
- //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
- mega1.shiftWrite(1, LOW); //DESLIGANDO Painel verde
- mega1.shiftWrite(35, LOW); //DESLIGANDO Painel vermelho 2
- delay(1000);
- mega1.shiftWrite(2, LOW);
- mega1.shiftWrite(36, LOW);
- delay(1000);
- mega1.shiftWrite(3, LOW);
- mega1.shiftWrite(37, LOW);
- delay(1000);
- mega1.shiftWrite(4, LOW);
- mega1.shiftWrite(38, LOW);
- delay(1000);
- mega1.shiftWrite(5, LOW);
- mega1.shiftWrite(39, LOW);
- delay(1000);
- mega1.shiftWrite(6, LOW);
- mega1.shiftWrite(40, LOW);
- delay(1000);
- mega1.shiftWrite(7, LOW);
- mega1.shiftWrite(41, LOW);
- delay(1000);
- mega1.shiftWrite(8, LOW);
- mega1.shiftWrite(42, LOW);
- delay(1000);
- mega1.shiftWrite(9, LOW);
- mega1.shiftWrite(43, LOW);
- delay(1000);
- mega1.shiftWrite(10, LOW);
- mega1.shiftWrite(44, LOW);
- delay(1000);
- }
- // ------------------------ Função Acende VM1 e VD2 e apaga um a um
- //FUNCIONA NORMAL A PARTE ABAIXO PARA LIGAR OS DOIS GRUPOS DE LED
- void painelVD2eVM1 ()
- {
- //2º Painel VERDE
- mega1.shiftWrite(25, HIGH); //DESLIGAR painel verde 2
- mega1.shiftWrite(26, HIGH);
- mega1.shiftWrite(27, HIGH);
- mega1.shiftWrite(28, HIGH);
- mega1.shiftWrite(29, HIGH);
- mega1.shiftWrite(30, HIGH);
- mega1.shiftWrite(31, HIGH);
- mega1.shiftWrite(32, HIGH);
- mega1.shiftWrite(33, HIGH);
- mega1.shiftWrite(34, HIGH);
- mega1.shiftWrite(11, HIGH); //LIGANDO painel vermelho 1
- mega1.shiftWrite(12, HIGH);
- mega1.shiftWrite(13, HIGH);
- mega1.shiftWrite(14, HIGH);
- mega1.shiftWrite(15, HIGH);
- mega1.shiftWrite(16, HIGH);
- mega1.shiftWrite(17, HIGH);
- mega1.shiftWrite(18, HIGH);
- mega1.shiftWrite(19, HIGH);
- mega1.shiftWrite(20, HIGH);
- delay(1000);
- //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
- mega1.shiftWrite(25, LOW); //DESLIGAR painel verde 2
- mega1.shiftWrite(11, LOW); //DESLIGAR painel vermelho 1
- delay(1000);
- mega1.shiftWrite(26, LOW);
- mega1.shiftWrite(12, LOW);
- delay(1000);
- mega1.shiftWrite(27, LOW);
- mega1.shiftWrite(13, LOW);
- delay(1000);
- mega1.shiftWrite(28, LOW);
- mega1.shiftWrite(14, LOW);
- delay(1000);
- mega1.shiftWrite(29, LOW);
- mega1.shiftWrite(15, LOW);
- delay(1000);
- mega1.shiftWrite(30, LOW);
- mega1.shiftWrite(16, LOW);
- delay(1000);
- mega1.shiftWrite(31, LOW);
- mega1.shiftWrite(17, LOW);
- delay(1000);
- mega1.shiftWrite(32, LOW);
- mega1.shiftWrite(18, LOW);
- delay(1000);
- mega1.shiftWrite(33, LOW);
- mega1.shiftWrite(19, LOW);
- delay(1000);
- mega1.shiftWrite(34, LOW);
- mega1.shiftWrite(20, LOW);
- delay(1000);
- }
- void setup()
- {
- }
- void loop()
- {
- painelVD1 ();
- painelVM1 ();
- painelVD2 ();
- painelVM2 ();
- painelVD1eVM2 ();
- painelVD2eVM1 ();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement