Skip to content

Instantly share code, notes, and snippets.

@ypelletier
Created August 18, 2013 17:56
Show Gist options
  • Save ypelletier/6262993 to your computer and use it in GitHub Desktop.
Save ypelletier/6262993 to your computer and use it in GitHub Desktop.
Horloge simple avec un Arduino, un module breakout RTC DS1307 et un afficheur LCD.
/************************************************************
Horloge Arduino
Horloge simple avec un Arduino, un module breakout
RTC DS1307 et un afficheur LCD.
Branchements du breakout RTC DS1307:
Gnd --> GND
Vcc --> 5 V
Sda --> analog pin A4
Scl --> analog pin A5
Branchements de l'afficheur LCD:
LCD RS pin --> digital pin 12
LCD Enable pin --> digital pin 11
LCD D4 pin --> digital pin 5
LCD D5 pin --> digital pin 4
LCD D6 pin --> digital pin 3
LCD D7 pin --> digital pin 2
LCD R/W pin --> ground
http://electroniqueamateur.blogspot.ca/2013/06/une-horloge-pour-votre-arduino-real.html
***************************************************/
#include <LiquidCrystal.h>
#include <Wire.h>
#include <RTClib.h>
RTC_DS1307 RTC;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
Wire.begin();
RTC.begin();
lcd.begin(16, 2);
}
void loop() {
DateTime now = RTC.now();
// l'heure sur la premiêre ligne du LCD
lcd.setCursor(0, 0);
lcd.print(now.hour());
lcd.print(":");
if (now.minute() < 10) {
lcd.print("0");
}
lcd.print(now.minute());
lcd.print(":");
if (now.second() < 10) {
lcd.print("0");
}
lcd.print(now.second());
// la date sur la deuxième ligne du LCD
lcd.setCursor(0, 1);
lcd.print(now.day());
lcd.print(" ");
switch (now.month()) {
case 1:
lcd.print("janvier");
break;
case 2:
lcd.print("fevrier");
break;
case 3:
lcd.print("mars");
break;
case 4:
lcd.print("avril");
break;
case 5:
lcd.print("mai");
break;
case 6:
lcd.print("juin");
break;
case 7:
lcd.print("juillet");
break;
case 8:
lcd.print("aout");
break;
case 9:
lcd.print("septembre");
break;
case 10:
lcd.print("octobre");
break;
case 11:
lcd.print("novembre");
break;
case 12:
lcd.print("decembre");
break;
}
lcd.print(" ");
lcd.print(now.year());
delay(1000);
lcd.clear();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment