Matériel :
LCD Serial 16x2 http://www.evola.fr/product_info.php/lcd-16x2-liaison-serie-grove-p-238
Horloge RTC DS1307 http://www.evola.fr/product_info.php/horloge-temps-reel-ds1307-p-156
Les branchements c'est ceux des tutos ...
1er test , branchement :
LCD Res.Var. 10K Leonardo
pin 1 GND pin milieu -
pin 2 VCC pin droite -
pin 3 V0 pin milieu -
pin 4 RS - pin 13
pin 5 R/W pin gauche
pin 6 E - pin 12
pin 7 - -
pin 8 - -
pin 9 - -
pin 10 - -
pin 11 D4 - pin 5
pin 12 D5 - pin 4
pin 13 D6 - pin 3
pin 14 D7 - pin 2
pin 15 - -
pin 16 - -
- pin droite 5V
pin gauche GND
code :
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);
}
=> ca marche nickel
2ième test (en laissant branché le LCD) :
RTC Leonardo
SCL SCL
SDA SDA
VCC 5V
GND GND
code:
#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();
delay(3000);
}
=> ca marche nickel
3ième test on melange les 2 codes :
code:
#include <LiquidCrystal.h>
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
Wire.begin();
RTC.begin();
if (! RTC.isrunning()) {
RTC.adjust(DateTime(__DATE__, __TIME__));
}
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
//lcd.print(millis()/1000);
DateTime now = RTC.now();
lcd.print("sec=");
lcd.print(now.second());
}
=> j'ai plus les milisec sur la 2ième ligne du LCD et j'ai des caractères japonnais à droite ...