Skip to content
MarcG edited this page Feb 22, 2015 · 1 revision

RTC (Real time clock):

Un Reloj en tiempo real(en inglés, real-time clock, RTC) es un reloj de un ordenador, incluido en un circuito integrado, que mantiene la hora actual.

El hardware:

Datasheet

Libreria:

Adafruit

Como conectar:

Schem RTC

// Date and time functions using a DS1307 RTC connected via I2C and Wire lib

// VCC to 5v
// SDA to A4
// SCL to A5

#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 RTC;

void setup () {
    Serial.begin(57600);
    Wire.begin();
    RTC.begin();
 
  if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }
 
}
 
void loop () {
    DateTime now = RTC.now();
 
    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();
 
    Serial.println();
    delay(3000);
}

Cómo sería el mismo código sin librerías

Ejercicios:

Reloj digital en la pantalla:

Solución

Reloj analogico:

Solución

Mostrar 2 zonas horarias (Barcelona + NY):

Solución

Hacer un relog bonito customizado:

Solución

<<< Volver

HOME

  • [Instalación y familiarización con el IDE] (Instalación y familiarización con el IDE)
  • [Bases de C] (Bases de C)
  • [Ejercicios] (Ejercicios)
  • [Programación de la Matriz de LEDs] (Programación de la Matriz de LEDs)

Clone this wiki locally