• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Problem z biblioteką DS1302 - LCD-Blue-I2C
#47
Możesz zerknąć na ten kod

#include <DS1302RTC.h>
#include <Time.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define BACKLIGHT_PIN 3
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7,3,POSITIVE);

const char *monthName[12] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};

void setup() {

lcd.begin(16, 2);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
}

void loop() {

tmElements_t tm;

if (RTC.read™) {

lcd.setCursor (0, 0);
LCDprint2digits(tm.Hour);
lcd.print(':');
LCDprint2digits(tm.Minute);
lcd.print(':');
LCDprint2digits(tm.Second);
lcd.setCursor (0, 1);
lcd.print(tm.Day);
lcd.print('/');
lcd.print(monthName[tm.Month-1]);
lcd.print('/');
lcd.print(tmYearToCalendar(tm.Year));


} else {
if (RTC.chipPresent()) {
lcd.println("DS1302 stoi. Uruchom Zegar");
}
else {
lcd.println("DS1302 blad oczczytu!");
lcd.println("sprawdz polaczenie");
}
delay(9000);
}
delay(1000);
}

//void print2digits(int number) {
// if (number >= 0 && number < 10) {
// Serial.write('0');
// }
// Serial.print(number);
//}

void LCDprint2digits(int number) {
if (number >= 0 && number < 10) {
lcd.write('0');
}
lcd.print(number);
}
 
Odpowiedź
  


Wiadomości w tym wątku
RE: Problem z biblioteką DS1302 - LCD-Blue-I2C - przez danyy11 - 23-01-2017, 15:43

Skocz do:


Przeglądający: 2 gości