RELÓGIO ROLANTE COM MATRIZ 5X7 E RTC DS1307



Retomando as postagens estou apresentando minha experiência com o chip DS1307 que é um relógio de tempo real. Este chip tem muitas funcionalidades em projetos com arduino como logar tempo e eventos. Neste post conectei o chip para gerar os dados de tempo e apresentá-los na matriz 5x7 que havia montado anteriormente.

Para ver o esquema da montagem da matriz 5x7 e outras informações importantes, use este link. Existe também um post com a matriz como termômetro usando o chip LM35 neste link.

O chip utilizado aqui é o modelo DS1307N que  faz parte de uma linha de RTC da Maxim e suporta temperaturas abaixo de zero, exitem outros que só funcionam acima de 0 graus e outros com  características como cristal embutido e etc.

Segue esquema de conexão com a arduino ( ATMEGA 328):




É importante conectar o pólo negativo da bateria ao terra do sistema vuntamente ao terra do chip, sem isso a leitura dos dados apresenta problemas.

Neste projeto o mais complicado foi conseguir uma forma de alojar todos os dados na memória do chip ATMEGA 328. Com as limitações que existem, é fácil obter os resultados mais estranhos quando a memória fica cheia. Para evitar isso é necessário usar a memória flash ao invés de utilizar a memória SRAM. Normalmente seria utilizado o comando PROGMEM.

O fato é que o comando PROGMEM é bem complicado e após pesquisar um pouco encontrei o seguinte link: Library to Ease Accessing Flash-based (PROGMEM) Data com uma biblioteca que facilita muito o uso do PROGMEM.

A partir dai consegui armazenar corretamente todos os arrays que formam cada um dos números que representam as leituras de tempo vindas do chip DS1307.

Segue o código (carregue neste link):

--------------------------------------------------------------------------------------------------------------------------------

/*

Claudio Miklos 25/07/2010 -  www.miklos.blog.br

62,65,65,65,62,     // O
0,0,33,127,1,       // 1
33,67,69,73,49,     // 2
34,65,73,73,54,     // 3
12,20,36,127,4,     // 4
114,81,81,81,78,    // 5
30,41,73,73,6,      // 6
64,71,72,80,96,     // 7
54,73,73,73,54,     // 8
48,73,73,74,60,     // 9
0,0,0,20,0,         // :
0,0,112,80,112,     // GRAU
0,0,0,0,0           // VAZIO

*/

#include "Wire.h"
#include "Flash.h"
#define DS1307_I2C_ADDRESS 0x68
int pin = 0;
int tempc = 0;
int tp=0;
int tt=0;
int colbin=0;
int latchpin = 8;
int clockpin = 7;
int datapin = 10;


//-------------------------------- FUNCOES RELOGIO------------------------------------

byte decToBcd(byte val)
{
   return ( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
   return ( (val/16*10) + (val%16) );
}
// 1) Sets the date and time on the ds1307
// 2) Starts the clock
// 3) Sets hour mode to 24 hour clock
// Assumes you're passing in valid numbers
void setDateDs1307(byte second,          // 0-59
byte minute,         // 0-59
byte hour,           // 1-23
byte dayOfWeek,      // 1-7
byte dayOfMonth,     // 1-28/29/30/31
byte month,          // 1-12
byte year)           // 0-99
{
   Wire.beginTransmission(DS1307_I2C_ADDRESS);
   Wire.send(0);
   Wire.send(decToBcd(second));     // 0 to bit 7 starts the clock
   Wire.send(decToBcd(minute));
   Wire.send(decToBcd(hour));
   Wire.send(decToBcd(dayOfWeek));
   Wire.send(decToBcd(dayOfMonth));
   Wire.send(decToBcd(month));
   Wire.send(decToBcd(year));
   Wire.send(0x10); // sends 0x10 (hex) 00010000 (binary) to control register - turns on square wave
   Wire.endTransmission();
}
// Gets the date and time from the ds1307
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
   // Reset the register pointer
   Wire.beginTransmission(DS1307_I2C_ADDRESS);
   Wire.send(0);
   Wire.endTransmission();
   Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
   // A few of these need masks because certain bits are control bits
   *second     = bcdToDec(Wire.receive() & 0x7f);
   *minute     = bcdToDec(Wire.receive());
   *hour       = bcdToDec(Wire.receive() & 0x3f); // Need to change this if 12 hour am/pm
   *dayOfWeek  = bcdToDec(Wire.receive());
   *dayOfMonth = bcdToDec(Wire.receive());
   *month       = bcdToDec(Wire.receive());
   *year        = bcdToDec(Wire.receive());
}

//---------------------------TEMPERATURA-------------------------------


FLASH_ARRAY (int,t0,0,0,0,0,0,62,65,65,65,62,0,62,65,65,65,62,0,112,80,112,0);
FLASH_ARRAY (int,t1,0,0,0,0,0,62,65,65,65,62,0,33,127,1,0,112,80,112,0);
FLASH_ARRAY (int,t2,0,0,0,0,0,62,65,65,65,62,0,33,67,69,73,49,0,112,80,112,0);
FLASH_ARRAY (int,t3,0,0,0,0,0,62,65,65,65,62,0,34,65,73,73,54,0,112,80,112,0);
FLASH_ARRAY (int,t4,0,0,0,0,0,62,65,65,65,62,0,12,20,36,127,4,0,112,80,112,0);
FLASH_ARRAY (int,t5,0,0,0,0,0,62,65,65,65,62,0,114,81,81,81,78,0,112,80,112,0);
FLASH_ARRAY (int,t6,0,0,0,0,0,62,65,65,65,62,0,30,41,73,73,6,0,112,80,112,0);
FLASH_ARRAY (int,t7,0,0,0,0,0,62,65,65,65,62,0,64,71,72,80,96,0,112,80,112,0);
FLASH_ARRAY (int,t8,0,0,0,0,0,62,65,65,65,62,0,54,73,73,73,54,0,112,80,112,0);
FLASH_ARRAY (int,t9,0,0,0,0,0,62,65,65,65,62,0,48,73,73,74,60,0,112,80,112,0);

FLASH_ARRAY (int,t10,0,0,0,0,0,33,127,1,0,62,65,65,65,62,0,112,80,112,0);
FLASH_ARRAY (int,t11,0,0,0,0,0,33,127,1,0,0,0,0,33,127,1,0,112,80,112,0);
FLASH_ARRAY (int,t12,0,0,0,0,0,33,127,1,0,0,33,67,69,73,49,0,112,80,112,0);
FLASH_ARRAY (int,t13,0,0,0,0,0,33,127,1,0,34,65,73,73,54,0,112,80,112,0);
FLASH_ARRAY (int,t14,0,0,0,0,0,33,127,1,0,12,20,36,127,4,0,112,80,112,0);
FLASH_ARRAY (int,t15,0,0,0,0,0,33,127,1,0,114,81,81,81,78,0,112,80,112,0);
FLASH_ARRAY (int,t16,0,0,0,0,0,33,127,1,0,30,41,73,73,6,0,112,80,112,0);
FLASH_ARRAY (int,t17,0,0,0,0,0,33,127,1,0,64,71,72,80,96,0,112,80,112,0);
FLASH_ARRAY (int,t18,0,0,0,0,0,33,127,1,0,54,73,73,73,54,0,112,80,112,0);
FLASH_ARRAY (int,t19,0,0,0,0,0,33,127,1,0,48,73,73,74,60,0,112,80,112,0);

FLASH_ARRAY (int,t20,0,0,0,0,0,33,67,69,73,49,0,62,65,65,65,62,0,112,80,112,0);
FLASH_ARRAY (int,t21,0,0,0,0,0,33,67,69,73,49,0,0,33,127,1,0,112,80,112,0);
FLASH_ARRAY (int,t22,0,0,0,0,0,33,67,69,73,49,0,0,33,67,69,73,49,0,112,80,112,0);
FLASH_ARRAY (int,t23,0,0,0,0,0,33,67,69,73,49,0,34,65,73,73,54,0,112,80,112,0);
FLASH_ARRAY (int,t24,0,0,0,0,0,33,67,69,73,49,0,12,20,36,127,4,0,112,80,112,0);
FLASH_ARRAY (int,t25,0,0,0,0,0,33,67,69,73,49,0,114,81,81,81,78,0,112,80,112,0);
FLASH_ARRAY (int,t26,0,0,0,0,0,33,67,69,73,49,0,30,41,73,73,6,0,112,80,112,0);
FLASH_ARRAY (int,t27,0,0,0,0,0,33,67,69,73,49,0,64,71,72,80,96,0,112,80,112,0);
FLASH_ARRAY (int,t28,0,0,0,0,0,33,67,69,73,49,0,54,73,73,73,54,0,112,80,112,0);
FLASH_ARRAY (int,t29,0,0,0,0,0,33,67,69,73,49,0,48,73,73,74,60,0,112,80,112,0);

FLASH_ARRAY (int,t30,0,0,0,0,0,34,65,73,73,54,0,62,65,65,65,62,0,112,80,112,0);
FLASH_ARRAY (int,t31,0,0,0,0,0,34,65,73,73,54,0,0,33,127,1,0,112,80,112,0);
/*
FLASH_ARRAY (int,t32,0,0,0,0,0,34,65,73,73,54,0,0,33,67,69,73,49,0,112,80,112,0);
FLASH_ARRAY (int,t33,0,0,0,0,0,34,65,73,73,54,0,34,65,73,73,54,0,112,80,112,0);
FLASH_ARRAY (int,t34,0,0,0,0,0,34,65,73,73,54,0,12,20,36,127,4,0,112,80,112,0);
FLASH_ARRAY (int,t35,0,0,0,0,0,34,65,73,73,54,0,114,81,81,81,78,0,112,80,112,0);
FLASH_ARRAY (int,t36,0,0,0,0,0,34,65,73,73,54,0,30,41,73,73,6,0,112,80,112,0);
FLASH_ARRAY (int,t37,0,0,0,0,0,34,65,73,73,54,0,64,71,72,80,96,0,112,80,112,0);
FLASH_ARRAY (int,t38,0,0,0,0,0,34,65,73,73,54,0,54,73,73,73,54,0,112,80,112,0);
FLASH_ARRAY (int,t39,0,0,0,0,0,34,65,73,73,54,0,48,73,73,74,60,0,112,80,112,0);

FLASH_ARRAY (int,t40,0,0,0,0,0,12,20,36,127,4,0,62,65,65,65,62,0,112,80,112,0);
FLASH_ARRAY (int,t41,0,0,0,0,0,12,20,36,127,4,0,0,33,127,1,0,112,80,112,0);
FLASH_ARRAY (int,t42,0,0,0,0,0,12,20,36,127,4,0,0,33,67,69,73,49,0,112,80,112,0);
FLASH_ARRAY (int,t43,0,0,0,0,0,12,20,36,127,4,0,34,65,73,73,54,0,112,80,112,0);
FLASH_ARRAY (int,t44,0,0,0,0,0,12,20,36,127,4,0,12,20,36,127,4,0,112,80,112,0);
FLASH_ARRAY (int,t45,0,0,0,0,0,12,20,36,127,4,0,114,81,81,81,78,0,112,80,112,0);
FLASH_ARRAY (int,t46,0,0,0,0,0,12,20,36,127,4,0,30,41,73,73,6,0,112,80,112,0);
FLASH_ARRAY (int,t47,0,0,0,0,0,12,20,36,127,4,0,64,71,72,80,96,0,112,80,112,0);
FLASH_ARRAY (int,t48,0,0,0,0,0,12,20,36,127,4,0,54,73,73,73,54,0,112,80,112,0);
FLASH_ARRAY (int,t49,0,0,0,0,0,12,20,36,127,4,0,48,73,73,74,60,0,112,80,112,0);

FLASH_ARRAY (int,t50,0,0,0,0,0,114,81,81,81,78,0,62,65,65,65,62,0,112,80,112,0);
FLASH_ARRAY (int,t51,0,0,0,0,0,114,81,81,81,78,0,0,33,127,1,0,112,80,112,0);
FLASH_ARRAY (int,t52,0,0,0,0,0,114,81,81,81,78,0,0,33,67,69,73,49,0,112,80,112,0);
FLASH_ARRAY (int,t53,0,0,0,0,0,114,81,81,81,78,0,34,65,73,73,54,0,112,80,112,0);
FLASH_ARRAY (int,t54,0,0,0,0,0,114,81,81,81,78,0,12,20,36,127,4,0,112,80,112,0);
FLASH_ARRAY (int,t55,0,0,0,0,0,114,81,81,81,78,0,114,81,81,81,78,0,112,80,112,0);
FLASH_ARRAY (int,t56,0,0,0,0,0,114,81,81,81,78,0,30,41,73,73,6,0,112,80,112,0);
FLASH_ARRAY (int,t57,0,0,0,0,0,114,81,81,81,78,0,64,71,72,80,96,0,112,80,112,0);
FLASH_ARRAY (int,t58,0,0,0,0,0,114,81,81,81,78,0,54,73,73,73,54,0,112,80,112,0);
FLASH_ARRAY (int,t59,0,0,0,0,0,114,81,81,81,78,0,48,73,73,74,60,0,112,80,112,0);
*/
//-------------------------------HORA--------------------------------------------

FLASH_ARRAY (int,h0,0,0,0,0,0,62,65,65,65,62,0,62,65,65,65,62,0,31,4,31,0);
FLASH_ARRAY (int,h1,0,0,0,0,0,62,65,65,65,62,0,33,127,1,0,31,4,31,0);
FLASH_ARRAY (int,h2,0,0,0,0,0,62,65,65,65,62,0,33,67,69,73,49,0,31,4,31,0);
FLASH_ARRAY (int,h3,0,0,0,0,0,62,65,65,65,62,0,34,65,73,73,54,0,31,4,31,0);
FLASH_ARRAY (int,h4,0,0,0,0,0,62,65,65,65,62,0,12,20,36,127,4,0,31,4,31,0);
FLASH_ARRAY (int,h5,0,0,0,0,0,62,65,65,65,62,0,114,81,81,81,78,0,31,4,31,0);
FLASH_ARRAY (int,h6,0,0,0,0,0,62,65,65,65,62,0,30,41,73,73,6,0,31,4,31,0);
FLASH_ARRAY (int,h7,0,0,0,0,0,62,65,65,65,62,0,64,71,72,80,96,0,31,4,31,0);
FLASH_ARRAY (int,h8,0,0,0,0,0,62,65,65,65,62,0,54,73,73,73,54,0,31,4,31,0);
FLASH_ARRAY (int,h9,0,0,0,0,0,62,65,65,65,62,0,48,73,73,74,60,0,31,4,31,0);

FLASH_ARRAY (int,h10,0,0,0,0,0,33,127,1,0,62,65,65,65,62,0,31,4,31,0);
FLASH_ARRAY (int,h11,0,0,0,0,0,33,127,1,0,0,0,0,33,127,1,0,31,4,31,0);
FLASH_ARRAY (int,h12,0,0,0,0,0,33,127,1,0,0,33,67,69,73,49,0,31,4,31,0);
FLASH_ARRAY (int,h13,0,0,0,0,0,33,127,1,0,34,65,73,73,54,0,31,4,31,0);
FLASH_ARRAY (int,h14,0,0,0,0,0,33,127,1,0,12,20,36,127,4,0,31,4,31,0);
FLASH_ARRAY (int,h15,0,0,0,0,0,33,127,1,0,114,81,81,81,78,0,31,4,31,0);
FLASH_ARRAY (int,h16,0,0,0,0,0,33,127,1,0,30,41,73,73,6,0,31,4,31,0);
FLASH_ARRAY (int,h17,0,0,0,0,0,33,127,1,0,64,71,72,80,96,0,31,4,31,0);
FLASH_ARRAY (int,h18,0,0,0,0,0,33,127,1,0,54,73,73,73,54,0,31,4,31,0);
FLASH_ARRAY (int,h19,0,0,0,0,0,33,127,1,0,48,73,73,74,60,0,31,4,31,0);

FLASH_ARRAY (int,h20,0,0,0,0,0,33,67,69,73,49,0,62,65,65,65,62,0,31,4,31,0);
FLASH_ARRAY (int,h21,0,0,0,0,0,33,67,69,73,49,0,0,33,127,1,0,31,4,31,0);
FLASH_ARRAY (int,h22,0,0,0,0,0,33,67,69,73,49,0,0,33,67,69,73,49,0,31,4,31,0);
FLASH_ARRAY (int,h23,0,0,0,0,0,33,67,69,73,49,0,34,65,73,73,54,0,31,4,31,0);
FLASH_ARRAY (int,h24,0,0,0,0,0,33,67,69,73,49,0,12,20,36,127,4,0,31,4,31,0);
FLASH_ARRAY (int,h25,0,0,0,0,0,33,67,69,73,49,0,114,81,81,81,78,0,31,4,31,0);
FLASH_ARRAY (int,h26,0,0,0,0,0,33,67,69,73,49,0,30,41,73,73,6,0,31,4,31,0);
FLASH_ARRAY (int,h27,0,0,0,0,0,33,67,69,73,49,0,64,71,72,80,96,0,31,4,31,0);
FLASH_ARRAY (int,h28,0,0,0,0,0,33,67,69,73,49,0,54,73,73,73,54,0,31,4,31,0);
FLASH_ARRAY (int,h29,0,0,0,0,0,33,67,69,73,49,0,48,73,73,74,60,0,31,4,31,0);

FLASH_ARRAY (int,h30,0,0,0,0,0,34,65,73,73,54,0,62,65,65,65,62,0,31,4,31,0);
FLASH_ARRAY (int,h31,0,0,0,0,0,34,65,73,73,54,0,0,33,127,1,0,31,4,31,0);
FLASH_ARRAY (int,h32,0,0,0,0,0,34,65,73,73,54,0,0,33,67,69,73,49,0,31,4,31,0);
FLASH_ARRAY (int,h33,0,0,0,0,0,34,65,73,73,54,0,34,65,73,73,54,0,31,4,31,0);
FLASH_ARRAY (int,h34,0,0,0,0,0,34,65,73,73,54,0,12,20,36,127,4,0,31,4,31,0);
FLASH_ARRAY (int,h35,0,0,0,0,0,34,65,73,73,54,0,114,81,81,81,78,0,31,4,31,0);
FLASH_ARRAY (int,h36,0,0,0,0,0,34,65,73,73,54,0,30,41,73,73,6,0,31,4,31,0);
FLASH_ARRAY (int,h37,0,0,0,0,0,34,65,73,73,54,0,64,71,72,80,96,0,31,4,31,0);
FLASH_ARRAY (int,h38,0,0,0,0,0,34,65,73,73,54,0,54,73,73,73,54,0,31,4,31,0);
FLASH_ARRAY (int,h39,0,0,0,0,0,34,65,73,73,54,0,48,73,73,74,60,0,31,4,31,0);

FLASH_ARRAY (int,h40,0,0,0,0,0,12,20,36,127,4,0,62,65,65,65,62,0,31,4,31,0);
FLASH_ARRAY (int,h41,0,0,0,0,0,12,20,36,127,4,0,0,33,127,1,0,31,4,31,0);
FLASH_ARRAY (int,h42,0,0,0,0,0,12,20,36,127,4,0,0,33,67,69,73,49,0,31,4,31,0);
FLASH_ARRAY (int,h43,0,0,0,0,0,12,20,36,127,4,0,34,65,73,73,54,0,31,4,31,0);
FLASH_ARRAY (int,h44,0,0,0,0,0,12,20,36,127,4,0,12,20,36,127,4,0,31,4,31,0);
FLASH_ARRAY (int,h45,0,0,0,0,0,12,20,36,127,4,0,114,81,81,81,78,0,31,4,31,0);
FLASH_ARRAY (int,h46,0,0,0,0,0,12,20,36,127,4,0,30,41,73,73,6,0,31,4,31,0);
FLASH_ARRAY (int,h47,0,0,0,0,0,12,20,36,127,4,0,64,71,72,80,96,0,31,4,31,0);
FLASH_ARRAY (int,h48,0,0,0,0,0,12,20,36,127,4,0,54,73,73,73,54,0,31,4,31,0);
FLASH_ARRAY (int,h49,0,0,0,0,0,12,20,36,127,4,0,48,73,73,74,60,0,31,4,31,0);

FLASH_ARRAY (int,h50,0,0,0,0,0,114,81,81,81,78,0,62,65,65,65,62,0,31,4,31,0);
FLASH_ARRAY (int,h51,0,0,0,0,0,114,81,81,81,78,0,0,33,127,1,0,31,4,31,0);
FLASH_ARRAY (int,h52,0,0,0,0,0,114,81,81,81,78,0,0,33,67,69,73,49,0,31,4,31,0);
FLASH_ARRAY (int,h53,0,0,0,0,0,114,81,81,81,78,0,34,65,73,73,54,0,31,4,31,0);
FLASH_ARRAY (int,h54,0,0,0,0,0,114,81,81,81,78,0,12,20,36,127,4,0,31,4,31,0);
FLASH_ARRAY (int,h55,0,0,0,0,0,114,81,81,81,78,0,114,81,81,81,78,0,31,4,31,0);
FLASH_ARRAY (int,h56,0,0,0,0,0,114,81,81,81,78,0,30,41,73,73,6,0,31,4,31,0);
FLASH_ARRAY (int,h57,0,0,0,0,0,114,81,81,81,78,0,64,71,72,80,96,0,31,4,31,0);
FLASH_ARRAY (int,h58,0,0,0,0,0,114,81,81,81,78,0,54,73,73,73,54,0,31,4,31,0);
FLASH_ARRAY (int,h59,0,0,0,0,0,114,81,81,81,78,0,48,73,73,74,60,0,31,4,31,0);


//-------------------------------MINUTO--------------------------------------------

FLASH_ARRAY (int,m0,0,0,0,0,0,62,65,65,65,62,0,62,65,65,65,62,0,15,4,15,0);
FLASH_ARRAY (int,m1,0,0,0,0,0,62,65,65,65,62,0,33,127,1,0,15,4,15,0);
FLASH_ARRAY (int,m2,0,0,0,0,0,62,65,65,65,62,0,33,67,69,73,49,0,15,4,15,0);
FLASH_ARRAY (int,m3,0,0,0,0,0,62,65,65,65,62,0,34,65,73,73,54,0,15,4,15,0);
FLASH_ARRAY (int,m4,0,0,0,0,0,62,65,65,65,62,0,12,20,36,127,4,0,15,4,15,0);
FLASH_ARRAY (int,m5,0,0,0,0,0,62,65,65,65,62,0,114,81,81,81,78,0,15,4,15,0);
FLASH_ARRAY (int,m6,0,0,0,0,0,62,65,65,65,62,0,30,41,73,73,6,0,15,4,15,0);
FLASH_ARRAY (int,m7,0,0,0,0,0,62,65,65,65,62,0,64,71,72,80,96,0,15,4,15,0);
FLASH_ARRAY (int,m8,0,0,0,0,0,62,65,65,65,62,0,54,73,73,73,54,0,15,4,15,0);
FLASH_ARRAY (int,m9,0,0,0,0,0,62,65,65,65,62,0,48,73,73,74,60,0,15,4,15,0);

FLASH_ARRAY (int,m10,0,0,0,0,0,33,127,1,0,62,65,65,65,62,0,15,4,15,0);
FLASH_ARRAY (int,m11,0,0,0,0,0,33,127,1,0,0,0,0,33,127,1,0,15,4,15,0);
FLASH_ARRAY (int,m12,0,0,0,0,0,33,127,1,0,0,33,67,69,73,49,0,15,4,15,0);
FLASH_ARRAY (int,m13,0,0,0,0,0,33,127,1,0,34,65,73,73,54,0,15,4,15,0);
FLASH_ARRAY (int,m14,0,0,0,0,0,33,127,1,0,12,20,36,127,4,0,15,4,15,0);
FLASH_ARRAY (int,m15,0,0,0,0,0,33,127,1,0,114,81,81,81,78,0,15,4,15,0);
FLASH_ARRAY (int,m16,0,0,0,0,0,33,127,1,0,30,41,73,73,6,0,15,4,15,0);
FLASH_ARRAY (int,m17,0,0,0,0,0,33,127,1,0,64,71,72,80,96,0,15,4,15,0);
FLASH_ARRAY (int,m18,0,0,0,0,0,33,127,1,0,54,73,73,73,54,0,15,4,15,0);
FLASH_ARRAY (int,m19,0,0,0,0,0,33,127,1,0,48,73,73,74,60,0,15,4,15,0);

FLASH_ARRAY (int,m20,0,0,0,0,0,33,67,69,73,49,0,62,65,65,65,62,0,15,4,15,0);
FLASH_ARRAY (int,m21,0,0,0,0,0,33,67,69,73,49,0,0,33,127,1,0,15,4,15,0);
FLASH_ARRAY (int,m22,0,0,0,0,0,33,67,69,73,49,0,0,33,67,69,73,49,0,15,4,15,0);
FLASH_ARRAY (int,m23,0,0,0,0,0,33,67,69,73,49,0,34,65,73,73,54,0,15,4,15,0);
FLASH_ARRAY (int,m24,0,0,0,0,0,33,67,69,73,49,0,12,20,36,127,4,0,15,4,15,0);
FLASH_ARRAY (int,m25,0,0,0,0,0,33,67,69,73,49,0,114,81,81,81,78,0,15,4,15,0);
FLASH_ARRAY (int,m26,0,0,0,0,0,33,67,69,73,49,0,30,41,73,73,6,0,15,4,15,0);
FLASH_ARRAY (int,m27,0,0,0,0,0,33,67,69,73,49,0,64,71,72,80,96,0,15,4,15,0);
FLASH_ARRAY (int,m28,0,0,0,0,0,33,67,69,73,49,0,54,73,73,73,54,0,15,4,15,0);
FLASH_ARRAY (int,m29,0,0,0,0,0,33,67,69,73,49,0,48,73,73,74,60,0,15,4,15,0);

FLASH_ARRAY (int,m30,0,0,0,0,0,34,65,73,73,54,0,62,65,65,65,62,0,15,4,15,0);
FLASH_ARRAY (int,m31,0,0,0,0,0,34,65,73,73,54,0,0,33,127,1,0,15,4,15,0);
FLASH_ARRAY (int,m32,0,0,0,0,0,34,65,73,73,54,0,0,33,67,69,73,49,0,15,4,15,0);
FLASH_ARRAY (int,m33,0,0,0,0,0,34,65,73,73,54,0,34,65,73,73,54,0,15,4,15,0);
FLASH_ARRAY (int,m34,0,0,0,0,0,34,65,73,73,54,0,12,20,36,127,4,0,15,4,15,0);
FLASH_ARRAY (int,m35,0,0,0,0,0,34,65,73,73,54,0,114,81,81,81,78,0,15,4,15,0);
FLASH_ARRAY (int,m36,0,0,0,0,0,34,65,73,73,54,0,30,41,73,73,6,0,15,4,15,0);
FLASH_ARRAY (int,m37,0,0,0,0,0,34,65,73,73,54,0,64,71,72,80,96,0,15,4,15,0);
FLASH_ARRAY (int,m38,0,0,0,0,0,34,65,73,73,54,0,54,73,73,73,54,0,15,4,15,0);
FLASH_ARRAY (int,m39,0,0,0,0,0,34,65,73,73,54,0,48,73,73,74,60,0,15,4,15,0);

FLASH_ARRAY (int,m40,0,0,0,0,0,12,20,36,127,4,0,62,65,65,65,62,0,15,4,15,0);
FLASH_ARRAY (int,m41,0,0,0,0,0,12,20,36,127,4,0,0,33,127,1,0,15,4,15,0);
FLASH_ARRAY (int,m42,0,0,0,0,0,12,20,36,127,4,0,0,33,67,69,73,49,0,15,4,15,0);
FLASH_ARRAY (int,m43,0,0,0,0,0,12,20,36,127,4,0,34,65,73,73,54,0,15,4,15,0);
FLASH_ARRAY (int,m44,0,0,0,0,0,12,20,36,127,4,0,12,20,36,127,4,0,15,4,15,0);
FLASH_ARRAY (int,m45,0,0,0,0,0,12,20,36,127,4,0,114,81,81,81,78,0,15,4,15,0);
FLASH_ARRAY (int,m46,0,0,0,0,0,12,20,36,127,4,0,30,41,73,73,6,0,15,4,15,0);
FLASH_ARRAY (int,m47,0,0,0,0,0,12,20,36,127,4,0,64,71,72,80,96,0,15,4,15,0);
FLASH_ARRAY (int,m48,0,0,0,0,0,12,20,36,127,4,0,54,73,73,73,54,0,15,4,15,0);
FLASH_ARRAY (int,m49,0,0,0,0,0,12,20,36,127,4,0,48,73,73,74,60,0,15,4,15,0);

FLASH_ARRAY (int,m50,0,0,0,0,0,114,81,81,81,78,0,62,65,65,65,62,0,15,4,15,0);
FLASH_ARRAY (int,m51,0,0,0,0,0,114,81,81,81,78,0,0,33,127,1,0,15,4,15,0);
FLASH_ARRAY (int,m52,0,0,0,0,0,114,81,81,81,78,0,0,33,67,69,73,49,0,15,4,15,0);
FLASH_ARRAY (int,m53,0,0,0,0,0,114,81,81,81,78,0,34,65,73,73,54,0,15,4,15,0);
FLASH_ARRAY (int,m54,0,0,0,0,0,114,81,81,81,78,0,12,20,36,127,4,0,15,4,15,0);
FLASH_ARRAY (int,m55,0,0,0,0,0,114,81,81,81,78,0,114,81,81,81,78,0,15,4,15,0);
FLASH_ARRAY (int,m56,0,0,0,0,0,114,81,81,81,78,0,30,41,73,73,6,0,15,4,15,0);
FLASH_ARRAY (int,m57,0,0,0,0,0,114,81,81,81,78,0,64,71,72,80,96,0,15,4,15,0);
FLASH_ARRAY (int,m58,0,0,0,0,0,114,81,81,81,78,0,54,73,73,73,54,0,15,4,15,0);
FLASH_ARRAY (int,m59,0,0,0,0,0,114,81,81,81,78,0,48,73,73,74,60,0,15,4,15,0);

//-----------------------------SEGUNDO---------------------------------------------

FLASH_ARRAY (int,s0,0,0,0,0,0,62,65,65,65,62,0,62,65,65,65,62,0,29,21,23,0);
FLASH_ARRAY (int,s1,0,0,0,0,0,62,65,65,65,62,0,33,127,1,0,29,21,23,0);
FLASH_ARRAY (int,s2,0,0,0,0,0,62,65,65,65,62,0,33,67,69,73,49,0,29,21,23,0);
FLASH_ARRAY (int,s3,0,0,0,0,0,62,65,65,65,62,0,34,65,73,73,54,0,29,21,23,0);
FLASH_ARRAY (int,s4,0,0,0,0,0,62,65,65,65,62,0,12,20,36,127,4,0,29,21,23,0);
FLASH_ARRAY (int,s5,0,0,0,0,0,62,65,65,65,62,0,114,81,81,81,78,0,29,21,23,0);
FLASH_ARRAY (int,s6,0,0,0,0,0,62,65,65,65,62,0,30,41,73,73,6,0,29,21,23,0);
FLASH_ARRAY (int,s7,0,0,0,0,0,62,65,65,65,62,0,64,71,72,80,96,0,29,21,23,0);
FLASH_ARRAY (int,s8,0,0,0,0,0,62,65,65,65,62,0,54,73,73,73,54,0,29,21,23,0);
FLASH_ARRAY (int,s9,0,0,0,0,0,62,65,65,65,62,0,48,73,73,74,60,0,29,21,23,0);

FLASH_ARRAY (int,s10,0,0,0,0,0,33,127,1,0,62,65,65,65,62,0,29,21,23,0);
FLASH_ARRAY (int,s11,0,0,0,0,0,33,127,1,0,0,0,0,33,127,1,0,29,21,23,0);
FLASH_ARRAY (int,s12,0,0,0,0,0,33,127,1,0,0,33,67,69,73,49,0,29,21,23,0);
FLASH_ARRAY (int,s13,0,0,0,0,0,33,127,1,0,34,65,73,73,54,0,29,21,23,0);
FLASH_ARRAY (int,s14,0,0,0,0,0,33,127,1,0,12,20,36,127,4,0,29,21,23,0);
FLASH_ARRAY (int,s15,0,0,0,0,0,33,127,1,0,114,81,81,81,78,0,29,21,23,0);
FLASH_ARRAY (int,s16,0,0,0,0,0,33,127,1,0,30,41,73,73,6,0,29,21,23,0);
FLASH_ARRAY (int,s17,0,0,0,0,0,33,127,1,0,64,71,72,80,96,0,29,21,23,0);
FLASH_ARRAY (int,s18,0,0,0,0,0,33,127,1,0,54,73,73,73,54,0,29,21,23,0);
FLASH_ARRAY (int,s19,0,0,0,0,0,33,127,1,0,48,73,73,74,60,0,29,21,23,0);

FLASH_ARRAY (int,s20,0,0,0,0,0,33,67,69,73,49,0,62,65,65,65,62,0,29,21,23,0);
FLASH_ARRAY (int,s21,0,0,0,0,0,33,67,69,73,49,0,0,33,127,1,0,29,21,23,0);
FLASH_ARRAY (int,s22,0,0,0,0,0,33,67,69,73,49,0,0,33,67,69,73,49,0,29,21,23,0);
FLASH_ARRAY (int,s23,0,0,0,0,0,33,67,69,73,49,0,34,65,73,73,54,0,29,21,23,0);
FLASH_ARRAY (int,s24,0,0,0,0,0,33,67,69,73,49,0,12,20,36,127,4,0,29,21,23,0);
FLASH_ARRAY (int,s25,0,0,0,0,0,33,67,69,73,49,0,114,81,81,81,78,0,29,21,23,0);
FLASH_ARRAY (int,s26,0,0,0,0,0,33,67,69,73,49,0,30,41,73,73,6,0,29,21,23,0);
FLASH_ARRAY (int,s27,0,0,0,0,0,33,67,69,73,49,0,64,71,72,80,96,0,29,21,23,0);
FLASH_ARRAY (int,s28,0,0,0,0,0,33,67,69,73,49,0,54,73,73,73,54,0,29,21,23,0);
FLASH_ARRAY (int,s29,0,0,0,0,0,33,67,69,73,49,0,48,73,73,74,60,0,29,21,23,0);

FLASH_ARRAY (int,s30,0,0,0,0,0,34,65,73,73,54,0,62,65,65,65,62,0,29,21,23,0);
FLASH_ARRAY (int,s31,0,0,0,0,0,34,65,73,73,54,0,0,33,127,1,0,29,21,23,0);
FLASH_ARRAY (int,s32,0,0,0,0,0,34,65,73,73,54,0,0,33,67,69,73,49,0,29,21,23,0);
FLASH_ARRAY (int,s33,0,0,0,0,0,34,65,73,73,54,0,34,65,73,73,54,0,29,21,23,0);
FLASH_ARRAY (int,s34,0,0,0,0,0,34,65,73,73,54,0,12,20,36,127,4,0,29,21,23,0);
FLASH_ARRAY (int,s35,0,0,0,0,0,34,65,73,73,54,0,114,81,81,81,78,0,29,21,23,0);
FLASH_ARRAY (int,s36,0,0,0,0,0,34,65,73,73,54,0,30,41,73,73,6,0,29,21,23,0);
FLASH_ARRAY (int,s37,0,0,0,0,0,34,65,73,73,54,0,64,71,72,80,96,0,29,21,23,0);
FLASH_ARRAY (int,s38,0,0,0,0,0,34,65,73,73,54,0,54,73,73,73,54,0,29,21,23,0);
FLASH_ARRAY (int,s39,0,0,0,0,0,34,65,73,73,54,0,48,73,73,74,60,0,29,21,23,0);

FLASH_ARRAY (int,s40,0,0,0,0,0,12,20,36,127,4,0,62,65,65,65,62,0,29,21,23,0);
FLASH_ARRAY (int,s41,0,0,0,0,0,12,20,36,127,4,0,0,33,127,1,0,29,21,23,0);
FLASH_ARRAY (int,s42,0,0,0,0,0,12,20,36,127,4,0,0,33,67,69,73,49,0,29,21,23,0);
FLASH_ARRAY (int,s43,0,0,0,0,0,12,20,36,127,4,0,34,65,73,73,54,0,29,21,23,0);
FLASH_ARRAY (int,s44,0,0,0,0,0,12,20,36,127,4,0,12,20,36,127,4,0,29,21,23,0);
FLASH_ARRAY (int,s45,0,0,0,0,0,12,20,36,127,4,0,114,81,81,81,78,0,29,21,23,0);
FLASH_ARRAY (int,s46,0,0,0,0,0,12,20,36,127,4,0,30,41,73,73,6,0,29,21,23,0);
FLASH_ARRAY (int,s47,0,0,0,0,0,12,20,36,127,4,0,64,71,72,80,96,0,29,21,23,0);
FLASH_ARRAY (int,s48,0,0,0,0,0,12,20,36,127,4,0,54,73,73,73,54,0,29,21,23,0);
FLASH_ARRAY (int,s49,0,0,0,0,0,12,20,36,127,4,0,48,73,73,74,60,0,29,21,23,0);

FLASH_ARRAY (int,s50,0,0,0,0,0,114,81,81,81,78,0,62,65,65,65,62,0,29,21,23,0);
FLASH_ARRAY (int,s51,0,0,0,0,0,114,81,81,81,78,0,0,33,127,1,0,29,21,23,0);
FLASH_ARRAY (int,s52,0,0,0,0,0,114,81,81,81,78,0,0,33,67,69,73,49,0,29,21,23,0);
FLASH_ARRAY (int,s53,0,0,0,0,0,114,81,81,81,78,0,34,65,73,73,54,0,29,21,23,0);
FLASH_ARRAY (int,s54,0,0,0,0,0,114,81,81,81,78,0,12,20,36,127,4,0,29,21,23,0);
FLASH_ARRAY (int,s55,0,0,0,0,0,114,81,81,81,78,0,114,81,81,81,78,0,29,21,23,0);
FLASH_ARRAY (int,s56,0,0,0,0,0,114,81,81,81,78,0,30,41,73,73,6,0,29,21,23,0);
FLASH_ARRAY (int,s57,0,0,0,0,0,114,81,81,81,78,0,64,71,72,80,96,0,29,21,23,0);
FLASH_ARRAY (int,s58,0,0,0,0,0,114,81,81,81,78,0,54,73,73,73,54,0,29,21,23,0);
FLASH_ARRAY (int,s59,0,0,0,0,0,114,81,81,81,78,0,48,73,73,74,60,0,29,21,23,0);


//-----------------------------MOVE TEMPERATURA-----------------------------------------

/*

void movetemp(int duration)

{
  
tempc = ( 5.0 * analogRead(pin) * 100.0) / 1024.0;
tp = tempc;

  {

   for (int xx=0; xx<=25; xx++)
   
   {
      for (int dd=0; dd
      
      {
         for (int q=0; q<5; q++)
         
         {
           colbin=xx+q;
           
           switch(tp){
   case 0:
     columndisplay1(t0[colbin], q,0);
      break;
   case 1:
      columndisplay1(t1[colbin], q,0);
      break;
   case 2:
      columndisplay1(t2[colbin], q,0);
      break;
   case 3:
      columndisplay1(t3[colbin], q,0);
      break;
   case 4:
      columndisplay1(t4[colbin], q,0);
      break;
   case 5:
      columndisplay1(t5[colbin], q,0);
      break;
   case 6:
      columndisplay1(t6[colbin], q,0);
      break;
   case 7:
     columndisplay1(t7[colbin], q,0);
      break;
   case 8:
      columndisplay1(t8[colbin], q,0);
      break;
   case 9:
      columndisplay1(t9[colbin], q,0);
      break;
   case 10:
      columndisplay1(t10[colbin], q,0);
      break;
   case 11:
      columndisplay1(t11[colbin], q,0);
      break;
   case 12:
      columndisplay1(t12[colbin], q,0);
      break;
   case 13:
      columndisplay1(t13[colbin], q,0);
      break;
   case 14:
      columndisplay1(t14[colbin], q,0);
      break;
   case 15:
      columndisplay1(t15[colbin], q,0);
      break;
   case 16:
     columndisplay1(t16[colbin], q,0);
      break;
   case 17:
      columndisplay1(t17[colbin], q,0);
      break;
   case 18:
      columndisplay1(t18[colbin], q,0);
      break;
   case 19:
      columndisplay1(t19[colbin], q,0);
      break;
   case 20:
      columndisplay1(t20[colbin], q,0);
      break;
   case 21:
      columndisplay1(t21[colbin], q,0);
      break;
   case 22:
      columndisplay1(t22[colbin], q,0);
      break;
   case 23:
     columndisplay1(t23[colbin], q,0);
      break;
   case 24:
      columndisplay1(t24[colbin], q,0);
      break;
   case 25:
      columndisplay1(t25[colbin], q,0);
      break;
   case 26:
      columndisplay1(t26[colbin], q,0);
      break;
   case 27:
      columndisplay1(t27[colbin], q,0);
      break;
   case 28:
      columndisplay1(t28[colbin], q,0);
      break;
   case 29:
      columndisplay1(t29[colbin], q,0);
      break;
   case 30:
     columndisplay1(t30[colbin], q,0);
      break; 
   case 31:
      columndisplay1(t31[colbin], q,0);
      break;
   }
         }
      }
   }
}
}

void columndisplay(int coldata, int column, int holdtime)

{
   int matrixcolumn[5] = {
     1,2,4,8,16};
   digitalWrite(latchpin, LOW);
   shiftOut(datapin, clockpin, MSBFIRST, matrixcolumn[column]);
   shiftOut(datapin, clockpin, MSBFIRST, coldata);
   digitalWrite(latchpin, HIGH);
   delay(holdtime);
}

*/

//-------------------------------------------------MOVE HORA-----------------------------------------------------------------------------//

void movehora(int duration)

{
 
   byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
   getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
   // tt = (minute, DEC);
    tt = hour;
    
  {

   for (int xx=0; xx<=18; xx++)
   
   {
      for (int dd=0; ddfor (int q=0; q<5; q++)
         
         {
           colbin=xx+q;
           
            switch(tt){
   case 0:
     columndisplay1(h0[colbin], q,0);
      break;
   case 1:
      columndisplay1(h1[colbin], q,0);
      break;
   case 2:
      columndisplay1(h2[colbin], q,0);
      break;
   case 3:
      columndisplay1(h3[colbin], q,0);
      break;
   case 4:
      columndisplay1(h4[colbin], q,0);
      break;
   case 5:
      columndisplay1(h5[colbin], q,0);
      break;
   case 6:
      columndisplay1(h6[colbin], q,0);
      break;
   case 7:
     columndisplay1(h7[colbin], q,0);
      break;
   case 8:
      columndisplay1(h8[colbin], q,0);
      break;
   case 9:
      columndisplay1(h9[colbin], q,0);
      break;
   case 10:
      columndisplay1(h10[colbin], q,0);
      break;
   case 11:
      columndisplay1(h11[colbin], q,0);
      break;
   case 12:
      columndisplay1(h12[colbin], q,0);
      break;
   case 13:
      columndisplay1(h13[colbin], q,0);
      break;
   case 14:
      columndisplay1(h14[colbin], q,0);
      break;
   case 15:
      columndisplay1(h15[colbin], q,0);
      break;
   case 16:
     columndisplay1(h16[colbin], q,0);
      break;
   case 17:
      columndisplay1(h17[colbin], q,0);
      break;
   case 18:
      columndisplay1(h18[colbin], q,0);
      break;
   case 19:
      columndisplay1(h19[colbin], q,0);
      break;
   case 20:
      columndisplay1(h20[colbin], q,0);
      break;
   case 21:
      columndisplay1(h21[colbin], q,0);
      break;
   case 22:
      columndisplay1(h22[colbin], q,0);
      break;
   case 23:
     columndisplay1(h23[colbin], q,0);
      break;
   case 24:
      columndisplay1(h24[colbin], q,0);
      break;
   case 25:
      columndisplay1(h25[colbin], q,0);
      break;
   case 26:
      columndisplay1(h26[colbin], q,0);
      break;
   case 27:
      columndisplay1(h27[colbin], q,0);
      break;
   case 28:
      columndisplay1(h28[colbin], q,0);
      break;
   case 29:
      columndisplay1(h29[colbin], q,0);
      break;
   case 30:
     columndisplay1(h30[colbin], q,0);
      break; 
   case 31:
      columndisplay1(h31[colbin], q,0);
      break;
   case 32:
      columndisplay1(h32[colbin], q,0);
      break;
   case 33:
      columndisplay1(h33[colbin], q,0);
      break;
   case 34:
      columndisplay1(h34[colbin], q,0);
      break;
   case 35:
      columndisplay1(h35[colbin], q,0);
      break;
   case 36:
      columndisplay1(h36[colbin], q,0);
      break;
   case 37:
      columndisplay1(h37[colbin], q,0);
      break;
   case 38:
      columndisplay1(h38[colbin], q,0);
      break;
   case 39:
     columndisplay1(h39[colbin], q,0);
      break;
   case 40:
      columndisplay1(h40[colbin], q,0);
      break; 
   case 41:
      columndisplay1(h41[colbin], q,0);
      break;
   case 42:
      columndisplay1(h42[colbin], q,0);
      break;
   case 43:
      columndisplay1(h43[colbin], q,0);
      break;
   case 44:
      columndisplay1(h44[colbin], q,0);
      break;
   case 45:
      columndisplay1(h45[colbin], q,0);
      break;
   case 46:
      columndisplay1(h46[colbin], q,0);
      break;
   case 47:
     columndisplay1(h47[colbin], q,0);
      break;
   case 48:
      columndisplay1(h48[colbin], q,0);
      break;
   case 49:
      columndisplay1(h49[colbin], q,0);
      break;
   case 50:
      columndisplay1(h50[colbin], q,0);
      break;
   case 51:
      columndisplay1(h51[colbin], q,0);
      break;
   case 52:
      columndisplay1(h52[colbin], q,0);
      break;
   case 53:
      columndisplay1(h53[colbin], q,0);
      break;
   case 54:
      columndisplay1(h54[colbin], q,0);
      break;
   case 55:
      columndisplay1(h55[colbin], q,0);
      break;
   case 56:
     columndisplay1(h56[colbin], q,0);
      break;
   case 57:
      columndisplay1(h57[colbin], q,0);
      break;
   case 58:
      columndisplay1(h58[colbin], q,0);
      break;
   case 59:
      columndisplay1(h59[colbin], q,0);
      break;
   }
         }
      }
   }
}
}

void columndisplay1(int coldata, int column, int holdtime)

{
   int matrixcolumn[5] = {
     1,2,4,8,16};
   digitalWrite(latchpin, LOW);
   shiftOut(datapin, clockpin, MSBFIRST, matrixcolumn[column]);
   shiftOut(datapin, clockpin, MSBFIRST, coldata);
   digitalWrite(latchpin, HIGH);
   delay(holdtime);
}


//-------------------------------------------------MOVE MINUTO-----------------------------------------------------------------------------//

void movemin(int duration)

{
 
   byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
   getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
   // tt = (minute, DEC);
    tt = minute;
    
   {

   for (int xx=0; xx<=18; xx++)
   
   {
      for (int dd=0; ddfor (int q=0; q<5; q++)
         
         {
           colbin=xx+q;
           
            switch(tt){
   case 0:
     columndisplay1(m0[colbin], q,0);
      break;
   case 1:
      columndisplay1(m1[colbin], q,0);
      break;
   case 2:
      columndisplay1(m2[colbin], q,0);
      break;
   case 3:
      columndisplay1(m3[colbin], q,0);
      break;
   case 4:
      columndisplay1(m4[colbin], q,0);
      break;
   case 5:
      columndisplay1(m5[colbin], q,0);
      break;
   case 6:
      columndisplay1(m6[colbin], q,0);
      break;
   case 7:
     columndisplay1(m7[colbin], q,0);
      break;
   case 8:
      columndisplay1(m8[colbin], q,0);
      break;
   case 9:
      columndisplay1(m9[colbin], q,0);
      break;
   case 10:
      columndisplay1(m10[colbin], q,0);
      break;
   case 11:
      columndisplay1(m11[colbin], q,0);
      break;
   case 12:
      columndisplay1(m12[colbin], q,0);
      break;
   case 13:
      columndisplay1(m13[colbin], q,0);
      break;
   case 14:
      columndisplay1(m14[colbin], q,0);
      break;
   case 15:
      columndisplay1(m15[colbin], q,0);
      break;
   case 16:
     columndisplay1(m16[colbin], q,0);
      break;
   case 17:
      columndisplay1(m17[colbin], q,0);
      break;
   case 18:
      columndisplay1(m18[colbin], q,0);
      break;
   case 19:
      columndisplay1(m19[colbin], q,0);
      break;
   case 20:
      columndisplay1(m20[colbin], q,0);
      break;
   case 21:
      columndisplay1(m21[colbin], q,0);
      break;
   case 22:
      columndisplay1(m22[colbin], q,0);
      break;
   case 23:
     columndisplay1(m23[colbin], q,0);
      break;
   case 24:
      columndisplay1(m24[colbin], q,0);
      break;
   case 25:
      columndisplay1(m25[colbin], q,0);
      break;
   case 26:
      columndisplay1(m26[colbin], q,0);
      break;
   case 27:
      columndisplay1(m27[colbin], q,0);
      break;
   case 28:
      columndisplay1(m28[colbin], q,0);
      break;
   case 29:
      columndisplay1(m29[colbin], q,0);
      break;
   case 30:
     columndisplay1(m30[colbin], q,0);
      break; 
   case 31:
      columndisplay1(m31[colbin], q,0);
      break;
   case 32:
      columndisplay1(m32[colbin], q,0);
      break;
   case 33:
      columndisplay1(m33[colbin], q,0);
      break;
   case 34:
      columndisplay1(m34[colbin], q,0);
      break;
   case 35:
      columndisplay1(m35[colbin], q,0);
      break;
   case 36:
      columndisplay1(m36[colbin], q,0);
      break;
   case 37:
      columndisplay1(m37[colbin], q,0);
      break;
   case 38:
      columndisplay1(m38[colbin], q,0);
      break;
   case 39:
     columndisplay1(m39[colbin], q,0);
      break;
   case 40:
      columndisplay1(m40[colbin], q,0);
      break; 
   case 41:
      columndisplay1(m41[colbin], q,0);
      break;
   case 42:
      columndisplay1(m42[colbin], q,0);
      break;
   case 43:
      columndisplay1(m43[colbin], q,0);
      break;
   case 44:
      columndisplay1(m44[colbin], q,0);
      break;
   case 45:
      columndisplay1(m45[colbin], q,0);
      break;
   case 46:
      columndisplay1(m46[colbin], q,0);
      break;
   case 47:
     columndisplay1(m47[colbin], q,0);
      break;
   case 48:
      columndisplay1(m48[colbin], q,0);
      break;
   case 49:
      columndisplay1(m49[colbin], q,0);
      break;
   case 50:
      columndisplay1(m50[colbin], q,0);
      break;
   case 51:
      columndisplay1(m51[colbin], q,0);
      break;
   case 52:
      columndisplay1(m52[colbin], q,0);
      break;
   case 53:
      columndisplay1(m53[colbin], q,0);
      break;
   case 54:
      columndisplay1(m54[colbin], q,0);
      break;
   case 55:
      columndisplay1(m55[colbin], q,0);
      break;
   case 56:
     columndisplay1(m56[colbin], q,0);
      break;
   case 57:
      columndisplay1(m57[colbin], q,0);
      break;
   case 58:
      columndisplay1(m58[colbin], q,0);
      break;
   case 59:
      columndisplay1(m59[colbin], q,0);
      break;
   }
         }
      }
   }
}
}

void columndisplay2(int coldata, int column, int holdtime)

{
   int matrixcolumn[5] = {
     1,2,4,8,16};
   digitalWrite(latchpin, LOW);
   shiftOut(datapin, clockpin, MSBFIRST, matrixcolumn[column]);
   shiftOut(datapin, clockpin, MSBFIRST, coldata);
   digitalWrite(latchpin, HIGH);
   delay(holdtime);
}

//----------------------------------------SEGUNDOS-----------------------------------------------------------------------------------------


void moveseg(int duration)

{
 
   byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
   getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
   // tt = (minute, DEC);
    tt = second;
    
   {

   for (int xx=0; xx<=18; xx++)
   
   {
      for (int dd=0; ddfor (int q=0; q<5; q++)
         
         {
           colbin=xx+q;
           
            switch(tt){
   case 0:
     columndisplay1(s0[colbin], q,0);
      break;
   case 1:
      columndisplay1(s1[colbin], q,0);
      break;
   case 2:
      columndisplay1(s2[colbin], q,0);
      break;
   case 3:
      columndisplay1(s3[colbin], q,0);
      break;
   case 4:
      columndisplay1(s4[colbin], q,0);
      break;
   case 5:
      columndisplay1(s5[colbin], q,0);
      break;
   case 6:
      columndisplay1(s6[colbin], q,0);
      break;
   case 7:
     columndisplay1(s7[colbin], q,0);
      break;
   case 8:
      columndisplay1(s8[colbin], q,0);
      break;
   case 9:
      columndisplay1(s9[colbin], q,0);
      break;
   case 10:
      columndisplay1(s10[colbin], q,0);
      break;
   case 11:
      columndisplay1(s11[colbin], q,0);
      break;
   case 12:
      columndisplay1(s12[colbin], q,0);
      break;
   case 13:
      columndisplay1(s13[colbin], q,0);
      break;
   case 14:
      columndisplay1(s14[colbin], q,0);
      break;
   case 15:
      columndisplay1(s15[colbin], q,0);
      break;
   case 16:
     columndisplay1(s16[colbin], q,0);
      break;
   case 17:
      columndisplay1(s17[colbin], q,0);
      break;
   case 18:
      columndisplay1(s18[colbin], q,0);
      break;
   case 19:
      columndisplay1(s19[colbin], q,0);
      break;
   case 20:
      columndisplay1(s20[colbin], q,0);
      break;
   case 21:
      columndisplay1(s21[colbin], q,0);
      break;
   case 22:
      columndisplay1(s22[colbin], q,0);
      break;
   case 23:
     columndisplay1(s23[colbin], q,0);
      break;
   case 24:
      columndisplay1(s24[colbin], q,0);
      break;
   case 25:
      columndisplay1(s25[colbin], q,0);
      break;
   case 26:
      columndisplay1(s26[colbin], q,0);
      break;
   case 27:
      columndisplay1(s27[colbin], q,0);
      break;
   case 28:
      columndisplay1(s28[colbin], q,0);
      break;
   case 29:
      columndisplay1(s29[colbin], q,0);
      break;
   case 30:
     columndisplay1(s30[colbin], q,0);
      break; 
   case 31:
      columndisplay1(s31[colbin], q,0);
      break;
   case 32:
      columndisplay1(s32[colbin], q,0);
      break;
   case 33:
      columndisplay1(s33[colbin], q,0);
      break;
   case 34:
      columndisplay1(s34[colbin], q,0);
      break;
   case 35:
      columndisplay1(s35[colbin], q,0);
      break;
   case 36:
      columndisplay1(s36[colbin], q,0);
      break;
   case 37:
      columndisplay1(s37[colbin], q,0);
      break;
   case 38:
      columndisplay1(s38[colbin], q,0);
      break;
   case 39:
     columndisplay1(s39[colbin], q,0);
      break;
   case 40:
      columndisplay1(s40[colbin], q,0);
      break; 
   case 41:
      columndisplay1(s41[colbin], q,0);
      break;
   case 42:
      columndisplay1(s42[colbin], q,0);
      break;
   case 43:
      columndisplay1(s43[colbin], q,0);
      break;
   case 44:
      columndisplay1(s44[colbin], q,0);
      break;
   case 45:
      columndisplay1(s45[colbin], q,0);
      break;
   case 46:
      columndisplay1(s46[colbin], q,0);
      break;
   case 47:
     columndisplay1(s47[colbin], q,0);
      break;
   case 48:
      columndisplay1(s48[colbin], q,0);
      break;
   case 49:
      columndisplay1(s49[colbin], q,0);
      break;
   case 50:
      columndisplay1(s50[colbin], q,0);
      break;
   case 51:
      columndisplay1(s51[colbin], q,0);
      break;
   case 52:
      columndisplay1(s52[colbin], q,0);
      break;
   case 53:
      columndisplay1(s53[colbin], q,0);
      break;
   case 54:
      columndisplay1(s54[colbin], q,0);
      break;
   case 55:
      columndisplay1(s55[colbin], q,0);
      break;
   case 56:
     columndisplay1(s56[colbin], q,0);
      break;
   case 57:
      columndisplay1(s57[colbin], q,0);
      break;
   case 58:
      columndisplay1(s58[colbin], q,0);
      break;
   case 59:
      columndisplay1(s59[colbin], q,0);
      break;
   }
         }
      }
   }
}
}

void columndisplay3(int coldata, int column, int holdtime)

{
   int matrixcolumn[5] = {
     1,2,4,8,16};
   digitalWrite(latchpin, LOW);
   shiftOut(datapin, clockpin, MSBFIRST, matrixcolumn[column]);
   shiftOut(datapin, clockpin, MSBFIRST, coldata);
   digitalWrite(latchpin, HIGH);
   delay(holdtime);
}




//----------------------------------------------------------------------------------------------------------------------------------------//



void setup()

{
   byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
   Wire.begin();
   Serial.begin(9600);
   second = 0;
   minute = 0;
   hour = 12;
   dayOfWeek = 3;
   dayOfMonth = 10;
   month = 8;
   year = 10;
   //setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
   pinMode(latchpin, OUTPUT);
   pinMode(clockpin, OUTPUT);
   pinMode(datapin, OUTPUT);  
}

void loop()

{
   
   movehora(20);
   movemin(20);
   moveseg(20);
   // movetemp(20);
 //Serial.print(tt);
 //delay(1000);

}





------------------------------------------------------------------------------------------

Como poderão ver no código existe também a opção de apresentar a temperatura com o uso do chip LM35, neste post eu comentei esta opção para apresentar somente o horário. No momento de apresentar a temperatura existe algum problema que causa confusão na animação da matriz, alguns dos leds se acendem em momentos aleatórios...caso algum dos leitores saiba como resolver por favor me informe.

Como sempre aviso nestes posts, meu código é feito por experimemnação e por isso está longe de ser perfeito ou mesmo razoável. Espero sempre sugetões e correções de outros usuários de arduino.

Pesquisas:

http://pdfserv.maxim-ic.com/en/ds/DS1307.pdf

http://isomk.sdf.org/arduino.html

http://www.newark.com/maxim-integrated-products/ds1307n/ic-rtc-yy-mm-dd-56-x-8-dip-8/dp/60K9237
 
http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/


 http://lusorobotica.com/index.php/topic,681.0.html


http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1235070596

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1264025351

http://www.sullivan-county.com/ele/arduino_ds1307.htm

http://lusorobotica.com/index.php?topic=681.0


http://www.sparkfun.com/commerce/product_info.php?products_id=99

http://www.glacialwanderer.com/hobbyrobotics/?p=12

http://scratchpad.thisandthose.org/scratchpad/article.php?story=20100126164621223

Internet of Things

LUX com arduino GPRS shield e sensor LDR.

/*
Graph: Feed 38642, Datastream lux
*/

Laboratórios, Lojas e Produtos

Blogs, Comunidades e Revistas