Miernik temperatury wilgotności i ciśnienia - zbyszek78 - 27-09-2015
Witam
Postanowiłem jako pierwszy projekt wykonać stację pomiarową, która będzie na wyświetlaczu LCD 20x4 wyświetlać
aktualną godzinę, datę, temperatury z 2 czujników, wilgotność i ciśnienie atmosferyczne.
Czujniki to:
Sonda wodoodporna z czujnikiem temperatury DS18B20
BME280 - czujnik wilgotności, temperatury oraz ciśnienia I2C/SPI - moduł Adafruit
W wyniku poszukiwań w sieci i wykorzystaniu kilku gotowych programów otrzymałem takie coś:
Kod: #include <DS1307RTC.h>
#include <Time.h>
#include <OneWire.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <LiquidCrystal_I2C.h>
#define BACKLIGHT_PIN 3
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);
#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10
#define SEALEVELPRESSURE_HPA (1013.25)
OneWire ds(10); // on pin 10 (a 4.7K resistor is necessary)
Adafruit_BME280 bme; // I2C
const char *monthName[12] = {
"01", "02", "03", "04", "05", "06",
"07", "08", "09", "10", "11", "12"
};
byte temp[8] = //ikona temperatury
{
B00100,
B01010,
B01010,
B01110,
B01110,
B11111,
B11111,
B01110
};
byte wilg[8] = //ikona wilgotnosci
{
B00100,
B00100,
B01010,
B10001,
B10001,
B10001,
B01110,
};
byte stopnie[8] = //ikona stopni
{
B01100,
B10010,
B10010,
B01100,
B00000,
B00000,
B00000,
B00000
};
void setup(void) {
Serial.begin(9600);
// Serial.println(F("BME280 test"));
lcd.begin(20, 4);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.createChar(0, temp);
lcd.createChar(1, wilg);
lcd.createChar(3, stopnie);
lcd.createChar(4, procent);
if (!bme.begin()) {
// Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
}
void loop() {
byte i;
byte present = 0;
byte type_s;
byte data[12];
byte addr[8];
float celsius, fahrenheit;
if ( !ds.search(addr)) {
// Serial.println("No more addresses.");
// Serial.println();
ds.reset_search();
// delay(1000);
return;
}
// Serial.print("ROM =");
for( i = 0; i < 8; i++) {
// Serial.write(' ');
// Serial.print(addr[i], HEX);
}
if (OneWire::crc8(addr, 7) != addr[7]) {
// Serial.println("CRC is not valid!");
return;
}
// Serial.println();
// the first ROM byte indicates which chip
switch (addr[0]) {
case 0x10:
// Serial.println(" Chip = DS18S20"); // or old DS1820
type_s = 1;
break;
case 0x28:
// Serial.println(" Chip = DS18B20");
type_s = 0;
break;
case 0x22:
// Serial.println(" Chip = DS1822");
type_s = 0;
break;
default:
// Serial.println("Device is not a DS18x20 family device.");
return;
}
ds.reset();
ds.select(addr);
ds.write(0x44, 1); // start conversion, with parasite power on at the end
// delay(1000);
// we might do a ds.depower() here, but the reset will take care of it.
present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
// Serial.print(" Data = ");
// Serial.print(present, HEX);
// Serial.print(" ");
for ( i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();
// Serial.print(data[i], HEX);
// Serial.print(" ");
}
// Serial.print(" CRC=");
// Serial.print(OneWire::crc8(data, 8), HEX);
// Serial.println();
// Convert the data to actual temperature
// because the result is a 16 bit signed integer, it should
// be stored to an "int16_t" type, which is always 16 bits
// even when compiled on a 32 bit processor.
int16_t raw = (data[1] << 8) | data[0];
if (type_s) {
raw = raw << 3; // 9 bit resolution default
if (data[7] == 0x10) {
// "count remain" gives full 12 bit resolution
raw = (raw & 0xFFF0) + 12 - data[6];
}
} else {
byte cfg = (data[4] & 0x60);
// at lower res, the low bits are undefined, so let's zero them
if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms
else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
//// default is 12 bit resolution, 750 ms conversion time
}
celsius = (float)raw / 16.0;
fahrenheit = celsius * 1.8 + 32.0;
// Serial.print(" Temperature = ");
// Serial.print(celsius);
// Serial.print(" Celsius, ");
// Serial.print(fahrenheit);
// Serial.println(" Fahrenheit");
//zegar
tmElements_t tm;
if (RTC.read(tm)) {
// lcd.setCursor (0, 0);
// lcd.print("Godzina");
lcd.setCursor (6, 0);
LCDprint2digits(tm.Hour);
lcd.print(':');
LCDprint2digits(tm.Minute);
lcd.print(':');
LCDprint2digits(tm.Second);
// lcd.setCursor (0, 1);
// lcd.print("Data");
lcd.setCursor (5, 1);
lcd.print(tm.Day);
lcd.print('/');
lcd.print(monthName[tm.Month-1]);
lcd.print('/');
lcd.print(tmYearToCalendar(tm.Year));
//wyswietlacz
lcd.setCursor (0, 2);
lcd.write(byte(0));
lcd.print("=");
lcd.print(bme.readTemperature(), 1);
lcd.write(byte(3));
lcd.print("C");
lcd.setCursor (9, 2);
lcd.print("P=");
lcd.print(bme.readPressure() / 100.0F, 1);
lcd.print("hPa");
lcd.setCursor (0, 3);
lcd.write(byte(0));
lcd.print("=");
lcd.print(celsius, 1);
lcd.write(byte(3));
lcd.print("C");
lcd.setCursor (9, 3);
lcd.write(byte(1));
lcd.write("=");
lcd.print(bme.readHumidity(), 1);
lcd.print("%");
} else {
if (RTC.chipPresent()) {
lcd.println("DS1307 stoi. Uruchom Zegar");
}
else {
lcd.println("DS1307 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);
//bme280
// Serial.print("Temperature = ");
// Serial.print(bme.readTemperature());
// Serial.println(" *C");
// Serial.print("Pressure = ");
// Serial.print(bme.readPressure() / 100.0F);
// Serial.println(" hPa");
// Serial.print("Approx. Altitude = ");
// Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
// Serial.println(" m");
// Serial.print("Humidity = ");
// Serial.print(bme.readHumidity());
// Serial.println(" %");
// Serial.println();
// delay(500);
}
Na początku zanim dodałem wyświetlacz LCD dane czytałem w konsoli dlatego cześć kodu dotycząca wysyłania danych do komputera jest wyłączona.
Zastanawiam się też nad możliwością wykonania programu tak aby na wyświetlaczu zmieniać ekrany np żeby godzina i data były na jednym ekranie a wielkości mierzone na drugim a zmiana następowała np co 5 s ale to już bardziej skomplikowane. Na szczęście jest na forum wątek o tym:
http://forum.arduinopolska.com/watek-kilka-stron-lcd
niestety na razie nie ogarniam tego.
Proszę o weryfikację, pomoc w uporządkowaniu tego i pomoc w ustawieniu opóźnienia tak aby zegar odświeżał się co sekundę a wielkości mierzone np co 2s.
RE: Miernik temperatury wilgotności i ciśnienia - JasQ - 27-09-2015
Proszę bardzo tu masz połączenie zmiany strony i czasowego przełączania z moich 2 ostatnich postów
Zmieniając interwał 5000 w lini poniżej zmieniasz po ilu sekundach ma się zmienić ekran z 1 na 2
if ( (millis()-czas) >= 5000 ){czas = millis();
Kod: #include <ShiftRegLCD123.h>
ShiftRegLCD123 srlcd( 7, 6, SRLCD123);
unsigned long czas = 0;
unsigned long z = 0 ;
byte lcd = 1;
byte strona = 1;
void setup() {
Serial.begin(9600);
srlcd.begin(16,2);
}
void loop() {
unsigned long sek = millis()/1000 ;
if ( (millis()-czas) >= 5000 ){czas = millis();
if (strona == 2){strona = 1;}
else if(strona == 1){strona = 2;}}
switch (strona) {
case 1:
if (lcd != 1){srlcd.clear();lcd = 1;} //czyszczenie ekranu 1
srlcd.setCursor(0,0);
srlcd.print("lcd 1 ");
srlcd.setCursor(0,1);
srlcd.print(millis());
break;
case 2:
if (lcd != 2){srlcd.clear();lcd = 2;} //czyszczenie ekranu 2
srlcd.setCursor(0,0);
srlcd.print("lcd 2 ");
srlcd.setCursor(0,1);
srlcd.print(sek);
srlcd.print(" sek. ");
break;
}
}
RE: Miernik temperatury wilgotności i ciśnienia - zbyszek78 - 27-09-2015
Dziękuję, tak jak wcześniej pisałem widziałem ten wątek problemem jest dla mnie gdzie to wpisać i jak podzielić co ma być gdzie wyświetlane.
RE: Miernik temperatury wilgotności i ciśnienia - JasQ - 27-09-2015
Wpisz tam gdzie jest u mnie
to przed "setup"
Kod: unsigned long czas = 0;
unsigned long z = 0 ;
byte lcd = 1;
byte strona = 1;
to na początku w "loop"
Kod: unsigned long sek = millis()/1000 ;
if ( (millis()-czas) >= 5000 ){czas = millis();
if (strona == 2){strona = 1;}
else if(strona == 1){strona = 2;}}
a to na końcu "loop"
Kod: switch (strona) {
case 1:
if (lcd != 1){srlcd.clear();lcd = 1;} //czyszczenie ekranu 1
// tutaj wpisz co chcesz mieć na stronie 1
break;
case 2:
if (lcd != 2){srlcd.clear();lcd = 2;} //czyszczenie ekranu 2
// tutaj wpisz co chcesz mieć na stronie 2
break;
}
łatwiej ci tego wytłumaczyć nie potrafię
RE: Miernik temperatury wilgotności i ciśnienia - zbyszek78 - 27-09-2015
Dziękuję za szybką pomoc, jutro będę próbował to ogarnąć. Co myślisz o moim programie? Jak załatwić sprawę opóźnienia?
RE: Miernik temperatury wilgotności i ciśnienia - JasQ - 27-09-2015
przed setup jeszcze 1 zmienna
Kod: unsigned long odczyt = 0;
a w loop w tej funkcji umieść kod odczytu z czujników
if ( (millis()-odczyt) >= 2000 ){
// tutaj wszystko związane z odczytem z czujników
odczyt = millis();
}
Zegar aktualizował się będzie sam co sekundę bo pomiędzy niema i tak nic nowego do wyświetlenia
RE: Miernik temperatury wilgotności i ciśnienia - zbyszek78 - 28-09-2015
Czy do tego potrzebna jest ta biblioteka?
#include <ShiftRegLCD123.h>
ShiftRegLCD123 srlcd( 7, 6, SRLCD123);
Jeżeli tak to gdzie można ją pobrać?
RE: Miernik temperatury wilgotności i ciśnienia - JasQ - 28-09-2015
To jest biblioteka do lcd na scalaku hc164 ty zamiast tego daj biblioteki z normalnego lcd a moje wyrzuć
RE: Miernik temperatury wilgotności i ciśnienia - zbyszek78 - 28-09-2015
Coś namieszałem i nie chce mi to działać
Kod wygląda teraz tak:
Kod: #include <DS1307RTC.h>
#include <Time.h>
#include <OneWire.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <LiquidCrystal_I2C.h>
#define BACKLIGHT_PIN 3
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);
#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10
#define SEALEVELPRESSURE_HPA (1013.25)
OneWire ds(10); // on pin 10 (a 4.7K resistor is necessary)
Adafruit_BME280 bme; // I2C
const char *monthName[12] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "09", "Oct", "Nov", "Dec"
};
byte temp[8] = //ikona temperatury
{
B00100,
B01010,
B01010,
B01110,
B01110,
B11111,
B11111,
B01110
};
byte wilg[8] = //ikona wilgotnosci
{
B00100,
B00100,
B01010,
B10001,
B10001,
B10001,
B01110,
};
byte stopnie[8] = //ikona stopni
{
B01100,
B10010,
B10010,
B01100,
B00000,
B00000,
B00000,
B00000
};
byte procent[8] = //ikona procentu
{
B00000,
B11000,
B11010,
B00110,
B01100,
B01011,
B00011,
B00000
};
unsigned long odczyt = 0; //forum
unsigned long czas = 0;//forum
unsigned long z = 0;//forum
byte lcd = 1;//forum
byte strona = 1; //forum
void setup(void) {
Serial.begin(9600);
// Serial.println(F("BME280 test"));
lcd.begin(20, 4);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.createChar(0, temp);
lcd.createChar(1, wilg);
lcd.createChar(3, stopnie);
lcd.createChar(4, procent);
if (!bme.begin()) {
// Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
}
void loop() {
unsigned long sek = millis()/1000 ;
if ( (millis()-czas) >= 5000 ){czas = millis();
if (strona == 2){strona = 1;}
else if(strona == 1){strona = 2;}}
if ( (millis()-odczyt) >= 2000 ){ //forum
byte i;
byte present = 0;
byte type_s;
byte data[12];
byte addr[8];
float celsius, fahrenheit;
if ( !ds.search(addr)) {
// Serial.println("No more addresses.");
// Serial.println();
ds.reset_search();
// delay(1000);
return;
}
// Serial.print("ROM =");
for( i = 0; i < 8; i++) {
// Serial.write(' ');
// Serial.print(addr[i], HEX);
}
if (OneWire::crc8(addr, 7) != addr[7]) {
// Serial.println("CRC is not valid!");
return;
}
// Serial.println();
// the first ROM byte indicates which chip
switch (addr[0]) {
case 0x10:
// Serial.println(" Chip = DS18S20"); // or old DS1820
type_s = 1;
break;
case 0x28:
// Serial.println(" Chip = DS18B20");
type_s = 0;
break;
case 0x22:
// Serial.println(" Chip = DS1822");
type_s = 0;
break;
default:
// Serial.println("Device is not a DS18x20 family device.");
return;
}
ds.reset();
ds.select(addr);
ds.write(0x44, 1);
// delay(1000);
present = ds.reset();
ds.select(addr);
ds.write(0xBE);
// Serial.print(" Data = ");
// Serial.print(present, HEX);
// Serial.print(" ");
for ( i = 0; i < 9; i++) {
data[i] = ds.read();
// Serial.print(data[i], HEX);
// Serial.print(" ");
}
// Serial.print(" CRC=");
// Serial.print(OneWire::crc8(data, 8), HEX);
// Serial.println();
int16_t raw = (data[1] << 8) | data[0];
if (type_s) {
raw = raw << 3; // 9 bit resolution default
if (data[7] == 0x10) {
// "count remain" gives full 12 bit resolution
raw = (raw & 0xFFF0) + 12 - data[6];
}
} else {
byte cfg = (data[4] & 0x60);
// at lower res, the low bits are undefined, so let's zero them
if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms
else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
//// default is 12 bit resolution, 750 ms conversion time
}
celsius = (float)raw / 16.0;
fahrenheit = celsius * 1.8 + 32.0;
// Serial.print(" Temperature = ");
// Serial.print(celsius);
// Serial.print(" Celsius, ");
// Serial.print(fahrenheit);
// Serial.println(" Fahrenheit");
case 1:
if (lcd != 1){srlcd.clear();lcd = 1;} //czyszczenie ekranu 1
lcd.setCursor (0, 2);
lcd.write(byte(0));
lcd.print("=");
lcd.print(bme.readTemperature(), 1);
lcd.write(byte(3));
lcd.print("C");
lcd.setCursor (9, 2);
lcd.print("P=");
lcd.print(bme.readPressure() / 100.0F, 1);
lcd.print("hPa");
lcd.setCursor (0, 3);
lcd.write(byte(0));
lcd.print("=");
lcd.print(celsius, 1);
lcd.write(byte(3));
lcd.print("C");
lcd.setCursor (9, 3);
lcd.write(byte(1));
lcd.write("=");
lcd.print(bme.readHumidity(), 1);
lcd.print("%");
odczyt = millis(); //forum
break;
}//forum
//zegar
tmElements_t tm;
if (RTC.read(tm)) {
case 2:
if (lcd != 2){srlcd.clear();lcd = 2;} //czyszczenie ekranu 2
}
// lcd.setCursor (0, 0);
// lcd.print("Godzina");
lcd.setCursor (6, 0);
LCDprint2digits(tm.Hour);
lcd.print(':');
LCDprint2digits(tm.Minute);
lcd.print(':');
LCDprint2digits(tm.Second);
// lcd.setCursor (0, 1);
// lcd.print("Data");
lcd.setCursor (5, 1);
lcd.print(tm.Day);
lcd.print('/');
lcd.print(monthName[tm.Month-1]);
lcd.print('/');
lcd.print(tmYearToCalendar(tm.Year));
//wyswietlacz
} else {
if (RTC.chipPresent()) {
lcd.println("DS1307 stoi. Uruchom Zegar");
}
else {
lcd.println("DS1307 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);
break;
//bme280
// Serial.print("Temperature = ");
// Serial.print(bme.readTemperature());
// Serial.println(" *C");
// Serial.print("Pressure = ");
// Serial.print(bme.readPressure() / 100.0F);
// Serial.println(" hPa");
// Serial.print("Approx. Altitude = ");
// Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
// Serial.println(" m");
// Serial.print("Humidity = ");
// Serial.print(bme.readHumidity());
// Serial.println(" %");
// Serial.println();
// delay(500);
switch (strona) {
}
I nie chce mi to działać.
Pomocy, co zrobiłem źle?
RE: Miernik temperatury wilgotności i ciśnienia - JasQ - 28-09-2015
no trochę nie zrozumiałeś a ja raczej kiepsko uczę poniżej kod , sprawdź czy działa ewentualnie napisz co tam w ardu na pomarańczowo pisze
niestety z tych komponentów które masz w programie mam tylko arduino a pisałem kod w ciemno bo i bibliotek takich nie mam
Kod: #include <DS1307RTC.h>
#include <Time.h>
#include <OneWire.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <LiquidCrystal_I2C.h>
#define BACKLIGHT_PIN 3
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);
#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10
#define SEALEVELPRESSURE_HPA (1013.25)
OneWire ds(10); // on pin 10 (a 4.7K resistor is necessary)
Adafruit_BME280 bme; // I2C
const char *monthName[12] = {
"01", "02", "03", "04", "05", "06",
"07", "08", "09", "10", "11", "12"
};
byte temp[8] = //ikona temperatury
{
B00100,
B01010,
B01010,
B01110,
B01110,
B11111,
B11111,
B01110
};
byte wilg[8] = //ikona wilgotnosci
{
B00100,
B00100,
B01010,
B10001,
B10001,
B10001,
B01110,
};
byte stopnie[8] = //ikona stopni
{
B01100,
B10010,
B10010,
B01100,
B00000,
B00000,
B00000,
B00000
};
byte i;
byte present = 0;
byte type_s;
byte data[12];
byte addr[8];
float celsius, fahrenheit;
unsigned long odczyt = 0;
unsigned long czas = 0;
unsigned long z = 0 ;
byte lcdx = 1;
byte strona = 1;
void setup(void) {
Serial.begin(9600);
lcd.begin(20, 4);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.createChar(0, temp);
lcd.createChar(1, wilg);
lcd.createChar(3, stopnie);
lcd.createChar(4, procent);
if (!bme.begin()) {while (1);}
}
void loop() {
unsigned long sek = millis()/1000 ;
if ( (millis()-czas) >= 5000 ){czas = millis();
if (strona == 2){strona = 1;}
else if(strona == 1){strona = 2;}}
if ( (millis()-odczyt) >= 2000 ){
if ( !ds.search(addr)){ds.reset_search();return;}
for( i = 0; i < 8; i++) { } // Ta linia niewiem po co jest niczemu nie służy ?!
if (OneWire::crc8(addr, 7) != addr[7]){return;}
switch (addr[0]) {
case 0x10:
type_s = 1;break;
case 0x28:
type_s = 0;break;
case 0x22:
type_s = 0;break;
default:
return;
}
ds.reset();
ds.select(addr);
ds.write(0x44, 1);
present = ds.reset();
ds.select(addr);
ds.write(0xBE);
for ( i = 0; i < 9; i++) {data[i] = ds.read();}
int16_t raw = (data[1] << 8) | data[0];
if (type_s) {raw = raw << 3;
if (data[7] == 0x10) {raw = (raw & 0xFFF0) + 12 - data[6];}}
else {byte cfg = (data[4] & 0x60);
if (cfg == 0x00) raw = raw & ~7;
else if (cfg == 0x20) raw = raw & ~3;}
celsius = (float)raw / 16.0;
fahrenheit = celsius * 1.8 + 32.0;
odczyt = millis();}
switch (strona) {
case 1:
if (lcdx != 1){lcd.clear();lcdx = 1;} //czyszczenie ekranu 1
lcd.setCursor (0, 2);
lcd.write(byte(0));
lcd.print("=");
lcd.print(bme.readTemperature(), 1);
lcd.write(byte(3));
lcd.print("C");
lcd.setCursor (9, 2);
lcd.print("P=");
lcd.print(bme.readPressure() / 100.0F, 1);
lcd.print("hPa");
lcd.setCursor (0, 3);
lcd.write(byte(0));
lcd.print("=");
lcd.print(celsius, 1);
lcd.write(byte(3));
lcd.print("C");
lcd.setCursor (9, 3);
lcd.write(byte(1));
lcd.write("=");
lcd.print(bme.readHumidity(), 1);
lcd.print("%");
break;
case 2:
if (lcdx != 2){lcd.clear();lcdx = 2;} //czyszczenie ekranu 2
tmElements_t tm;
if (RTC.read(tm)) {
lcd.setCursor (6, 0);
LCDprint2digits(tm.Hour);
lcd.print(':');
LCDprint2digits(tm.Minute);
lcd.print(':');
LCDprint2digits(tm.Second);
lcd.setCursor (5, 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("DS1307 stoi. Uruchom Zegar");}
else {lcd.println("DS1307 blad oczczytu!");
lcd.println("sprawdz polaczenie");}}
break;
}}
void LCDprint2digits(int number) {
if (number >= 0 && number < 10) {lcd.write('0');}
lcd.print(number);
}
|