12-01-2018, 23:13
Skice test wyświetlacza jako pierwszy:
#include <Wire.h>
#include <LiquidCrystal_PCF8574.h>
LiquidCrystal_PCF8574 lcd(0x27); // set the LCD address to 0x27 for a 16 chars and 2 line display
int show;
void setup()
{
int error;
Serial.begin(115200);
Serial.println("LCD...");
while (! Serial);
Serial.println("Dose: check for LCD");
// See http://playground.arduino.cc/Main/I2cScanner
Wire.begin();
Wire.beginTransmission(0x27);
error = Wire.endTransmission();
Serial.print("Error: ");
Serial.print(error);
if (error == 0) {
Serial.println(": LCD found.");
} else {
Serial.println(": LCD not found.");
} // if
lcd.begin(16, 2); // initialize the lcd
show = 0;
} // setup()
void loop()
{
if (show == 0) {
lcd.setBacklight(255);
lcd.home(); lcd.clear();
lcd.print("Hello LCD");
delay(1000);
lcd.setBacklight(0);
delay(400);
lcd.setBacklight(255);
} else if (show == 1) {
lcd.clear();
lcd.print("Cursor On");
lcd.cursor();
} else if (show == 2) {
lcd.clear();
lcd.print("Cursor Blink");
lcd.blink();
} else if (show == 3) {
lcd.clear();
lcd.print("Cursor OFF");
lcd.noBlink();
lcd.noCursor();
} else if (show == 4) {
lcd.clear();
lcd.print("Display Off");
lcd.noDisplay();
} else if (show == 5) {
lcd.clear();
lcd.print("Display On");
lcd.display();
} else if (show == 7) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("*** first line.");
lcd.setCursor(0, 1);
lcd.print("*** second line.");
} else if (show == 8) {
lcd.scrollDisplayLeft();
} else if (show == 9) {
lcd.scrollDisplayLeft();
} else if (show == 10) {
lcd.scrollDisplayLeft();
} else if (show == 11) {
lcd.scrollDisplayRight();
} // if
delay(2000);
show = (show + 1) % 12;
} // loop()
TEST ZEGARA SZKIC DRUGI: (z jakiegoś powoidu ten test nie wchodzi)
/*
test_RTC1302.ino
Il programma verifica il funzionamento del modulo MH-Real-Time
Clock Module 2 mostrando data e ora su Monitor seriale o
Display LCD 16x2 collegato tramite interfaccia I2C
Basato su libreria di Henning Karlsen
web: http://www.RinkyDinkElectronics.com/
Sono utilizzati i seguenti pin
Pin +5V -> Alimentazione modulo display e RTC
Pin GND -> GND modulo modulo display e RTC
Pin Digital 2 -> Pin CE - RST modulo RTC
Pin Digital 3 -> Pin I/O - DAT modulo RTC
Pin Digital 4 -> Pin CLCK - CLK modulo RTC
Pin Analogic A4 -> Pin SDA display
Pin Analogic A5 -> Pin SCL display
Creato il 15/12/2016 da Adriano Gandolfo
Sito web http://www.adrirobot.it
Blog http://it.emcelettronica.com/author/adrirobot
Pagina Facebook https://www.facebook.com/Adrirobot-318949048122955
Istagram https://www.instagram.com/adrirobot/
This example code is in the public domain.
*/
#include <DS1302.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Creazione oggetto RTC
DS1302 rtc(2, 3, 4);
// Creazione dell'oggetto LCD
// Imposta l'indirizzo LCD 0x27 per un display a 16 caratteri e 2 linee
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
// Imposta RTC in run-mode e disabilita la protezione da scrittura
rtc.halt(false);
rtc.writeProtect(false);
// Imposta la comunicazione seriale
Serial.begin(9600);
// inizializza il display
lcd.init();
lcd.backlight();//accende la retroilluminazione
// Le seguenti linee possono essere commentate per
//utilizzare i valori già memorizzati nel DS1302
//rtc.setDOW(SUNDAY); // Imposta il giorno della settimana a SUNDAY
//rtc.setTime(11, 32, 0); // Imposta l'ora come 11:32:00 (Formato 24hr)
//rtc.setDate(12, 2, 2017); // Imposta la data cone 12 febbraio 2017
}
void loop()
{
// Invia giorno della settimana
Serial.print(rtc.getDOWStr());
Serial.print(" ");
// Invia data
Serial.print(rtc.getDateStr());
Serial.print(" -- ");
// Invia ora
Serial.println(rtc.getTimeStr());
// Scrive i valori sul display LCD
lcd.clear();//cancella precedenti valori
data (); // Scrive su LCD la data
ora (); // Scrive su LCD l'ora
// Aspetta un secondo prima di ripetere
delay (1000);
}
void data ()
{
lcd.setCursor(0, 0);
lcd.print(rtc.getDOWStr());
lcd.print(" ");
lcd.print(rtc.getDateStr());
}
void ora()
{
lcd.setCursor(0, 1);
lcd.print(rtc.getTimeStr());
}
#include <Wire.h>
#include <LiquidCrystal_PCF8574.h>
LiquidCrystal_PCF8574 lcd(0x27); // set the LCD address to 0x27 for a 16 chars and 2 line display
int show;
void setup()
{
int error;
Serial.begin(115200);
Serial.println("LCD...");
while (! Serial);
Serial.println("Dose: check for LCD");
// See http://playground.arduino.cc/Main/I2cScanner
Wire.begin();
Wire.beginTransmission(0x27);
error = Wire.endTransmission();
Serial.print("Error: ");
Serial.print(error);
if (error == 0) {
Serial.println(": LCD found.");
} else {
Serial.println(": LCD not found.");
} // if
lcd.begin(16, 2); // initialize the lcd
show = 0;
} // setup()
void loop()
{
if (show == 0) {
lcd.setBacklight(255);
lcd.home(); lcd.clear();
lcd.print("Hello LCD");
delay(1000);
lcd.setBacklight(0);
delay(400);
lcd.setBacklight(255);
} else if (show == 1) {
lcd.clear();
lcd.print("Cursor On");
lcd.cursor();
} else if (show == 2) {
lcd.clear();
lcd.print("Cursor Blink");
lcd.blink();
} else if (show == 3) {
lcd.clear();
lcd.print("Cursor OFF");
lcd.noBlink();
lcd.noCursor();
} else if (show == 4) {
lcd.clear();
lcd.print("Display Off");
lcd.noDisplay();
} else if (show == 5) {
lcd.clear();
lcd.print("Display On");
lcd.display();
} else if (show == 7) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("*** first line.");
lcd.setCursor(0, 1);
lcd.print("*** second line.");
} else if (show == 8) {
lcd.scrollDisplayLeft();
} else if (show == 9) {
lcd.scrollDisplayLeft();
} else if (show == 10) {
lcd.scrollDisplayLeft();
} else if (show == 11) {
lcd.scrollDisplayRight();
} // if
delay(2000);
show = (show + 1) % 12;
} // loop()
TEST ZEGARA SZKIC DRUGI: (z jakiegoś powoidu ten test nie wchodzi)
/*
test_RTC1302.ino
Il programma verifica il funzionamento del modulo MH-Real-Time
Clock Module 2 mostrando data e ora su Monitor seriale o
Display LCD 16x2 collegato tramite interfaccia I2C
Basato su libreria di Henning Karlsen
web: http://www.RinkyDinkElectronics.com/
Sono utilizzati i seguenti pin
Pin +5V -> Alimentazione modulo display e RTC
Pin GND -> GND modulo modulo display e RTC
Pin Digital 2 -> Pin CE - RST modulo RTC
Pin Digital 3 -> Pin I/O - DAT modulo RTC
Pin Digital 4 -> Pin CLCK - CLK modulo RTC
Pin Analogic A4 -> Pin SDA display
Pin Analogic A5 -> Pin SCL display
Creato il 15/12/2016 da Adriano Gandolfo
Sito web http://www.adrirobot.it
Blog http://it.emcelettronica.com/author/adrirobot
Pagina Facebook https://www.facebook.com/Adrirobot-318949048122955
Istagram https://www.instagram.com/adrirobot/
This example code is in the public domain.
*/
#include <DS1302.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Creazione oggetto RTC
DS1302 rtc(2, 3, 4);
// Creazione dell'oggetto LCD
// Imposta l'indirizzo LCD 0x27 per un display a 16 caratteri e 2 linee
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
// Imposta RTC in run-mode e disabilita la protezione da scrittura
rtc.halt(false);
rtc.writeProtect(false);
// Imposta la comunicazione seriale
Serial.begin(9600);
// inizializza il display
lcd.init();
lcd.backlight();//accende la retroilluminazione
// Le seguenti linee possono essere commentate per
//utilizzare i valori già memorizzati nel DS1302
//rtc.setDOW(SUNDAY); // Imposta il giorno della settimana a SUNDAY
//rtc.setTime(11, 32, 0); // Imposta l'ora come 11:32:00 (Formato 24hr)
//rtc.setDate(12, 2, 2017); // Imposta la data cone 12 febbraio 2017
}
void loop()
{
// Invia giorno della settimana
Serial.print(rtc.getDOWStr());
Serial.print(" ");
// Invia data
Serial.print(rtc.getDateStr());
Serial.print(" -- ");
// Invia ora
Serial.println(rtc.getTimeStr());
// Scrive i valori sul display LCD
lcd.clear();//cancella precedenti valori
data (); // Scrive su LCD la data
ora (); // Scrive su LCD l'ora
// Aspetta un secondo prima di ripetere
delay (1000);
}
void data ()
{
lcd.setCursor(0, 0);
lcd.print(rtc.getDOWStr());
lcd.print(" ");
lcd.print(rtc.getDateStr());
}
void ora()
{
lcd.setCursor(0, 1);
lcd.print(rtc.getTimeStr());
}