Olá Garaginos

Estou desenvolvendo um projeto utilizando o CI 74hc595 utilizando a biblioteca ShiftOutMega.h, que facilita todo o trabalho, não necessitando trabalhar valores hexadecimais.

Esta parte do projeto é um contador regressivo de segundos 60 - 00.

Problema:

Preciso controlar a execução através de uma variável (informar por qual segundo começar). Já tentei algumas possibilidades, mas não tive sucesso.

Segue abaixo parte do código(para não ficar muito grande), para entendimento.

Ficarei agradecido pelas colaborações.

/*

- Pino 8 do Arduino ligado ao pino 12 do CI.
- Pino 11 do Arduino ligado ao pino 14 do CI.
- Pino 12 do Arduino ligado ao pino 11 do CI.

- Led 1 = Pino 15 do CI.
- Led 2 = Pino 1 do CI.
- Led 3 = Pino 2 do CI.
- Led 4 = Pino 3 do CI.
- Led 5 = Pino 4 do CI.
- Led 6 = Pino 5 do CI.
- Led 7 = Pino 6 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 de uso dos registradores 74HC595
int latchPin = 8; //Pino 8 conectado ao pino 12 do 74HC595 (Latch).
int dataPin = 11; //Pino 11 conectado ao pino 14 do 74HC595 (Data).
int clockPin = 12; //Pino 12 conectado ao pino 11 do 74HC595 (Clock).

//Quantidade de registradores (74HC595). Para cada registrador, temos 8 saídas.
int qtdRegistradores = 10;

ShiftOutMega mega(latchPin, dataPin, clockPin, qtdRegistradores); //Inicia a biblioteca passando os parametros de uso.

void setup(){

}

void loop(){

mega.shiftWrite(1, LOW); //A1
mega.shiftWrite(2, HIGH); //B1
mega.shiftWrite(3, HIGH); //C1
mega.shiftWrite(4, LOW); //D1
mega.shiftWrite(5, LOW); //E1
mega.shiftWrite(6, LOW); //F1
mega.shiftWrite(7, LOW); //G1 //NUMERO 10
mega.shiftWrite(8, HIGH); //A2
mega.shiftWrite(9, HIGH); //B2
mega.shiftWrite(10, HIGH); //C2
mega.shiftWrite(11, HIGH); //D2
mega.shiftWrite(12, HIGH); //E2
mega.shiftWrite(13, HIGH); //F2
mega.shiftWrite(14, LOW); //G2
delay(1000);

mega.shiftWrite(1, HIGH); //A1
mega.shiftWrite(2, HIGH); //B1
mega.shiftWrite(3, HIGH); //C1
mega.shiftWrite(4, HIGH); //D1
mega.shiftWrite(5, HIGH); //E1
mega.shiftWrite(6, HIGH); //F1
mega.shiftWrite(7, LOW); //G1 //NUMERO 09
mega.shiftWrite(8, HIGH); //A2
mega.shiftWrite(9, HIGH); //B2
mega.shiftWrite(10, HIGH); //C2
mega.shiftWrite(11, HIGH); //D2
mega.shiftWrite(12, LOW); //E2
mega.shiftWrite(13, HIGH); //F2
mega.shiftWrite(14, HIGH); //G2
delay(1000);

mega.shiftWrite(1, HIGH); //A1
mega.shiftWrite(2, HIGH); //B1
mega.shiftWrite(3, HIGH); //C1
mega.shiftWrite(4, HIGH); //D1
mega.shiftWrite(5, HIGH); //E1
mega.shiftWrite(6, HIGH); //F1
mega.shiftWrite(7, LOW); //G1 //NUMERO 08
mega.shiftWrite(8, HIGH); //A2
mega.shiftWrite(9, HIGH); //B2
mega.shiftWrite(10, HIGH); //C2
mega.shiftWrite(11, HIGH); //D2
mega.shiftWrite(12, HIGH); //E2
mega.shiftWrite(13, HIGH); //F2
mega.shiftWrite(14, HIGH); //G2
delay(1000);

mega.shiftWrite(1, HIGH); //A1
mega.shiftWrite(2, HIGH); //B1
mega.shiftWrite(3, HIGH); //C1
mega.shiftWrite(4, HIGH); //D1
mega.shiftWrite(5, HIGH); //E1
mega.shiftWrite(6, HIGH); //F1
mega.shiftWrite(7, LOW); //G1 //NUMERO 07
mega.shiftWrite(8, HIGH); //A2
mega.shiftWrite(9, HIGH); //B2
mega.shiftWrite(10, HIGH); //C2
mega.shiftWrite(11, LOW); //D2
mega.shiftWrite(12, LOW); //E2
mega.shiftWrite(13, LOW); //F2
mega.shiftWrite(14, LOW); //G2
delay(1000);

mega.shiftWrite(1, HIGH); //A1
mega.shiftWrite(2, HIGH); //B1
mega.shiftWrite(3, HIGH); //C1
mega.shiftWrite(4, HIGH); //D1
mega.shiftWrite(5, HIGH); //E1
mega.shiftWrite(6, HIGH); //F1
mega.shiftWrite(7, LOW); //G1 //NUMERO 06
mega.shiftWrite(8, HIGH); //A2
mega.shiftWrite(9, LOW); //B2
mega.shiftWrite(10, HIGH); //C2
mega.shiftWrite(11, HIGH); //D2
mega.shiftWrite(12, HIGH); //E2
mega.shiftWrite(13, HIGH); //F2
mega.shiftWrite(14, HIGH); //G2
delay(1000);

mega.shiftWrite(1, HIGH); //A1
mega.shiftWrite(2, HIGH); //B1
mega.shiftWrite(3, HIGH); //C1
mega.shiftWrite(4, HIGH); //D1
mega.shiftWrite(5, HIGH); //E1
mega.shiftWrite(6, HIGH); //F1
mega.shiftWrite(7, LOW); //G1 //NUMERO 05
mega.shiftWrite(8, HIGH); //A2
mega.shiftWrite(9, LOW); //B2
mega.shiftWrite(10, HIGH); //C2
mega.shiftWrite(11, HIGH); //D2
mega.shiftWrite(12, LOW); //E2
mega.shiftWrite(13, HIGH); //F2
mega.shiftWrite(14, HIGH); //G2
delay(1000);

mega.shiftWrite(1, HIGH); //A1
mega.shiftWrite(2, HIGH); //B1
mega.shiftWrite(3, HIGH); //C1
mega.shiftWrite(4, HIGH); //D1
mega.shiftWrite(5, HIGH); //E1
mega.shiftWrite(6, HIGH); //F1
mega.shiftWrite(7, LOW); //G1 //NUMERO 04
mega.shiftWrite(8, LOW); //A2
mega.shiftWrite(9, HIGH); //B2
mega.shiftWrite(10, HIGH); //C2
mega.shiftWrite(11, LOW); //D2
mega.shiftWrite(12, LOW); //E2
mega.shiftWrite(13, HIGH); //F2
mega.shiftWrite(14, HIGH); //G2
delay(1000);

mega.shiftWrite(1, HIGH); //A1
mega.shiftWrite(2, HIGH); //B1
mega.shiftWrite(3, HIGH); //C1
mega.shiftWrite(4, HIGH); //D1
mega.shiftWrite(5, HIGH); //E1
mega.shiftWrite(6, HIGH); //F1
mega.shiftWrite(7, LOW); //G1 //NUMERO 03
mega.shiftWrite(8, HIGH); //A2
mega.shiftWrite(9, HIGH); //B2
mega.shiftWrite(10, HIGH); //C2
mega.shiftWrite(11, HIGH); //D2
mega.shiftWrite(12, LOW); //E2
mega.shiftWrite(13, LOW); //F2
mega.shiftWrite(14, HIGH); //G2
delay(1000);

mega.shiftWrite(1, HIGH); //A1
mega.shiftWrite(2, HIGH); //B1
mega.shiftWrite(3, HIGH); //C1
mega.shiftWrite(4, HIGH); //D1
mega.shiftWrite(5, HIGH); //E1
mega.shiftWrite(6, HIGH); //F1
mega.shiftWrite(7, LOW); //G1 //NUMERO 02
mega.shiftWrite(8, HIGH); //A2
mega.shiftWrite(9, HIGH); //B2
mega.shiftWrite(10, LOW); //C2
mega.shiftWrite(11, HIGH); //D2
mega.shiftWrite(12, HIGH); //E2
mega.shiftWrite(13, LOW); //F2
mega.shiftWrite(14, HIGH); //G2
delay(1000);

mega.shiftWrite(1, HIGH); //A1
mega.shiftWrite(2, HIGH); //B1
mega.shiftWrite(3, HIGH); //C1
mega.shiftWrite(4, HIGH); //D1
mega.shiftWrite(5, HIGH); //E1
mega.shiftWrite(6, HIGH); //F1
mega.shiftWrite(7, LOW); //G1 //NUMERO 01
mega.shiftWrite(8, LOW); //A2
mega.shiftWrite(9, HIGH); //B2
mega.shiftWrite(10, HIGH); //C2
mega.shiftWrite(11, LOW); //D2
mega.shiftWrite(12, LOW); //E2
mega.shiftWrite(13, LOW); //F2
mega.shiftWrite(14, LOW); //G2
delay(1000);

mega.shiftWrite(1, HIGH); //A1
mega.shiftWrite(2, HIGH); //B1
mega.shiftWrite(3, HIGH); //C1
mega.shiftWrite(4, HIGH); //D1
mega.shiftWrite(5, HIGH); //E1
mega.shiftWrite(6, HIGH); //F1
mega.shiftWrite(7, LOW); //G1 //NUMERO 00
mega.shiftWrite(8, HIGH); //A2
mega.shiftWrite(9, HIGH); //B2
mega.shiftWrite(10, HIGH); //C2
mega.shiftWrite(11, HIGH); //D2
mega.shiftWrite(12, HIGH); //E2
mega.shiftWrite(13, HIGH); //F2
mega.shiftWrite(14, LOW); //G2
delay(1000);

}

Exibições: 858

Responder esta

Respostas a este tópico

Ruyter acho que vou complicar, mas.... existem alguns módulos display 4 dígitos chineses que usam o HC595... são 2 x hc595 para 4 x displays... um tal de Jason Berger (arduinoall) fez um código exemplo e depois Phaisarn, alterou algumas coisas.... ele é muito parecido com o que vc quer porém mais complexo pois multiplexa os displays.... ele criou uma tabela para os caracteres... o zero é o led aceso!!! acredito que os pinos estão ligados assim:

PINO DISPLAY "HC595"

A=128     "QH 595"
B=64       "QG 595"
C=32       "QF 595"
D=16       "QE 595"
E=8         "QD 595"
F=4         "QC 595"
G=2        "QB 595"
DP=1      "QA 595"

  

//character set (0-9)0-9

//                      (10-19)0.-9.

//                      (20-45)A-Z

//                      (46-71)a-z

//                      (72)- (73) space (74) º

intcharacters[]={

3,159,37,13,153,73,65,31,1,9,

2,158,36,12,152,72,64,30,0,8,

17,1,99,3,97,113,67,145,243,135,145,227,85,19,3,49,25,115,73,31,129,129,169,145,137,37,

5,193,229,133,33,113,9,209,247,143,81,227,85,213,197,49,25,245,73,225,199,199,169,145,137,37,

253,255,57

};

Talvez tabelar vá facilitar! Voce só vai precisar da 1ª e 2ª linha da tabela..

Neste nível não consegui captar mesmo! kkk

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço