Created
February 11, 2015 13:45
-
-
Save nilsonpessim/35ee46b0c8cf7d8493b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <virtuabotixRTC.h> | |
virtuabotixRTC myRTC(6, 7, 8); | |
void setup() | |
{ | |
Serial.begin(9600); | |
// Uma vez setada a data e a hora, a linha abaixo deve ser comentada e o programa novamente carregado no Arduino. | |
myRTC.setDS1302Time(00, 58, 23, 2, 17, 11, 2014); | |
} | |
void loop() | |
{ | |
myRTC.updateTime(); | |
Serial.print("Data : "); | |
imprime_dia_da_semana(myRTC.dayofweek); | |
Serial.print(", "); | |
Serial.print(myRTC.dayofmonth); | |
Serial.print("/"); | |
Serial.print(myRTC.month); | |
Serial.print("/"); | |
Serial.print(myRTC.year); | |
Serial.print(" "); | |
Serial.print("Hora : "); | |
if (myRTC.hours < 10) | |
{ | |
Serial.print("0"); | |
} | |
Serial.print(myRTC.hours); | |
Serial.print(":"); | |
if (myRTC.minutes < 10) | |
{ | |
Serial.print("0"); | |
} | |
Serial.print(myRTC.minutes); | |
Serial.print(":"); | |
if (myRTC.seconds < 10) | |
{ | |
Serial.print("0"); | |
} | |
Serial.println(myRTC.seconds); | |
delay( 1000); | |
} | |
void imprime_dia_da_semana(int dia) | |
{ | |
switch (dia) | |
{ | |
case 1: | |
Serial.print("Domingo"); | |
break; | |
case 2: | |
Serial.print("Segunda"); | |
break; | |
case 3: | |
Serial.print("Terca"); | |
break; | |
case 4: | |
Serial.print("Quarta"); | |
break; | |
case 5: | |
Serial.print("Quinta"); | |
break; | |
case 6: | |
Serial.print("Sexta"); | |
break; | |
case 7: | |
Serial.print("Sabado"); | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment