Você está na página 1de 7

Real Time Clock DS1307 (RTC) + Arduino

1 de 7

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

16/11/2013 00:15

Real Time Clock DS1307 (RTC) + Arduino

2 de 7

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

16/11/2013 00:15

Real Time Clock DS1307 (RTC) + Arduino

3 de 7

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

Arduino - Linha Completa


www.multilogica-shop.com
Representante oficial no Brasil com envio imediato para todo o pas.

16/11/2013 00:15

Real Time Clock DS1307 (RTC) + Arduino

4 de 7

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

for(byte i=0;i<7;i++)rtc[i]=ds1307get(i, 0);

ds1307get(i, 0)

int ds1307get(byte c, boolean refresh)

16/11/2013 00:15

Real Time Clock DS1307 (RTC) + Arduino

5 de 7

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

switch(c){
case DS1307_SEG:
v=(10*((rtc_bcd[DS1307_SEG] & DS1307_HI_SEG)>>4))+(rtc_bcd[DS1307_SEG]
break;
case DS1307_MIN:

DS1307_SEG

10*((rtc_bcd[DS1307_SEG] & DS1307_HI_SEG)>>4))+(rtc_bcd[DS1307_SEG] & DS13

void ds1307get(int *rtc, boolean refresh){

// Adquire os dados do ar

if(refresh) ds1307read();
for(byte i=0;i<7;i++)rtc[i]=ds1307get(i, 0);

// Percorre cada elemento

}
int ds1307get(byte c, boolean refresh){
if(refresh) ds1307read();
int v=-1;

// Adquire cada elemento da data


// Se der "fezes" tem de retornar

switch(c){
case DS1307_SEG:
v=(10*((rtc_bcd[DS1307_SEG] & DS1307_HI_SEG)>>4))+(rtc_bcd[DS1307_SEG]
break;
case DS1307_MIN:
v=(10*((rtc_bcd[DS1307_MIN] & DS1307_HI_MIN)>>4))+(rtc_bcd[DS1307_MIN]
break;
case DS1307_HR:

16/11/2013 00:15

Real Time Clock DS1307 (RTC) + Arduino

6 de 7

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

...
switch(c){
case DS1307_SEG:
v=(10*((rtc_bcd[DS1307_SEG] & DS1307_HI_SEG)>>4))+(rtc_bcd[DS1307_SEG]
// inseres a linha que se segue
Serial.println(rtc_bcd[DS1307_SEG], BIN); // Esta linha, Atencao esta
// inseres a linha de cima, a que passou :P
break;
case DS1307_MIN:
v=(10*((rtc_bcd[DS1307_MIN] & DS1307_HI_MIN)>>4))+(rtc_bcd[DS1307_MIN]
break;
...

16/11/2013 00:15

Real Time Clock DS1307 (RTC) + Arduino

7 de 7

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

Arduino Kit Iniciante


www.labdegaragem.org/loja
Eletrnica, programao e robtica Nota fiscal, garantia e suporte

=> Tutoriais OK

'

,
'

16/11/2013 00:15

Você também pode gostar