Page 1 of 1
2x LCD arduino IC2 / Matrix.dll
Posted: April 11th, 2024, 11:26 am
by h3rm3s80
ITA:Buongiorno, vorrei utilizzare 2/3/4/5 ecc LCD HD44780 con arduino e I2C con LCD SMARTIE
LCD SMARTIE è ancora il mio preferito da 20 anni
grazie
--------------------
ENG:Good morning, I would like to use 2/3/4/5 etc. LCD HD44780 with arduino and I2C with SMARTIE LCD
LCD SMARTIE is still my favorite for 20 years
Thank you
Re: 2x LCD arduino IC2 / Matrix.dll
Posted: April 17th, 2024, 2:22 pm
by fruittool
So is this multiple LCD from one arduino?
Different lines to different LCD or all lines duplicated on all LCD's?
Re: 2x LCD arduino IC2 / Matrix.dll
Posted: April 18th, 2024, 8:09 am
by h3rm3s80
ITA vorrei utlizzarlo come unico grande LCD, per visualizzare più informazioni contemporaneamente
ENG: I would like to use it as the only large LCD, to view more information at once
Re: 2x LCD arduino IC2 / Matrix.dll
Posted: April 23rd, 2024, 8:52 pm
by fruittool
OK, this sounds more like an arduino project than an LCD Smartie project.
Do you already have an arduino sketch for one display?
Take a look at
https://lastminuteengineers.com/i2c-lcd ... -tutorial/ for information on I2C Address of LCD.
Each screen needs its own address.
This is a modification of
https://wokwi.com/projects/380977007024415745 using 2 of 16x2 LCDs
image_2024-04-23_205120300.png
Code: Select all
#include <LiquidCrystal_I2C.h>
#define I2C1_ADDR 0x27
#define I2C2_ADDR 0x26
#define lcd_COLUMNS 16
#define lcd_LINES 2
LiquidCrystal_I2C lcd1(I2C1_ADDR, lcd_COLUMNS, lcd_LINES);
LiquidCrystal_I2C lcd2(I2C2_ADDR, lcd_COLUMNS, lcd_LINES);
void setup() {
Serial.begin(9600);
// set up the lcd1's number of rows and columns:
lcd1.init();
lcd1.clear();
lcd1.backlight();
lcd1.setCursor(0,0);
lcd1.print("LCD Smartie");
lcd1.setCursor(0,1);
lcd1.print("LCD 1");
lcd2.init();
lcd2.clear();
lcd2.backlight();
lcd2.setCursor(0,0);
lcd2.print("LCD Smartie");
lcd2.setCursor(0,1);
lcd2.print("LCD 2");
}
byte serial_getch(){
int incoming;
while (Serial.available()==0){}
// read the incoming byte:
incoming = Serial.read();
return (byte) (incoming &0xff);
}
void loop(){
byte rxbyte;
byte temp;
int controller;
byte custompos;
byte customchar[8];
rxbyte = serial_getch();
if (rxbyte == 254) //Matrix Orbital uses 254 prefix for commands
{
switch (serial_getch())
{
case 66: //backlight on (at previously set brightness)
// not implemented
break;
case 70: //backlight off
// not implemented
break;
case 71: //set cursor position
temp = (serial_getch() - 1); //get column byte
switch (serial_getch()) //get row byte
{
case 1:
controller=1;
lcd1.command(0b10000000 + temp);
break;
case 2:
controller=1;
temp += 0x40;
lcd1.command(0b10000000 + temp);
break;
case 3:
controller=2;
lcd2.command(0b10000000 + temp);
break;
case 4:
controller=2;
temp += 0x40;
lcd2.command(0b10000000 + temp);
break;
}
break;
case 72: //cursor home (reset display position)
lcd1.command(2);
break;
case 74: //show underline cursor
lcd1.command(0b00001110);
break;
case 75: //underline cursor off
case 84: //block cursor off
lcd1.command(0b00001100);
break;
case 76: //move cursor left
lcd1.command(16);
break;
case 77: //move cursor right
lcd1.command(20);
break;
case 78: //define custom char
custompos = serial_getch();
for (temp = 0; temp != 8; temp++)
{
customchar[temp]=serial_getch(); //get each pattern byte
}
lcd1.createChar(custompos, customchar);
lcd2.createChar(custompos, customchar);
break;
case 83: //show blinking block cursor
lcd1.command(0b00001111);
break;
case 86: //GPO OFF
//implement later
break;
case 87: //GPO ON
/*temp = serial_getch();
if (temp == 1)
{
GPO1 = GPO_ON;
}*/
break;
case 88: //clear display, cursor home
lcd1.command(1);
break;
case 152: //set and remember (doesn't save value, though)
case 153: //set backlight brightness
//not implemented
break;
//these commands ignored (no parameters)
case 35: //read serial number
case 36: //read version number
case 55: //read module type
case 59: //exit flow-control mode
case 65: //auto transmit keypresses
case 96: //auto-repeat mode off (keypad)
case 67: //auto line-wrap on
case 68: //auto line-wrap off
case 81: //auto scroll on
case 82: //auto scroll off
case 104: //init horiz bar graph
case 109: //init med size digits
case 115: //init narrow vert bar graph
case 118: //init wide vert bar graph
break;
default:
//all other commands ignored and parameter byte discarded
temp = serial_getch(); //dump the command code
break;
}
return;
} //END OF COMMAND HANDLER
//change accented char to plain, detect and change descenders
//NB descenders only work on 5x10 displays. This lookup table works
// with my DEM-20845 (Display Elektronik GmbH) lcd1 using KS0066 chip.
switch (rxbyte)
{
//chars that have direct equivalent in lcd1 charmap
/* case 0x67: //g
rxbyte = 0xE7;
break;
case 0x6A: //j
rxbyte = 0xEA;
break;
case 0x70: //p
rxbyte = 0xF0;
break;
case 0x71: //q
rxbyte = 0xF1;
break;
case 0x79: //y
rxbyte = 0xF9;
break;
*/ case 0xE4: //ASCII "a" umlaut
rxbyte = 0xE1;
break;
case 0xF1: //ASCII "n" tilde
rxbyte = 0xEE;
break;
case 0xF6: //ASCII "o" umlaut
rxbyte = 0xEF; //was wrong in v0.86
break;
case 0xFC: //ASCII "u" umlaut
rxbyte = 0xF5;
break;
//accented -> plain equivalent
//and misc symbol translation
case 0xA3: //sterling (pounds)
rxbyte = 0xED;
break;
/* case 0xB0: //degrees symbol
rxbyte = 0xDF;
break;
*/ case 0xB5: //mu
rxbyte = 0xE4;
break;
case 0xC0: //"A" variants
case 0xC1:
case 0xC2:
case 0xC3:
case 0xC4:
case 0xC5:
rxbyte = 0x41;
break;
case 0xC8: //"E" variants
case 0xC9:
case 0xCA:
case 0xCB:
rxbyte = 0x45;
break;
case 0xCC: //"I" variants
case 0xCD:
case 0xCE:
case 0xCF:
rxbyte = 0x49;
break;
case 0xD1: //"N" tilde -> plain "N"
rxbyte = 0x43;
break;
case 0xD2: //"O" variants
case 0xD3:
case 0xD4:
case 0xD5:
case 0xD6:
case 0xD8:
rxbyte = 0x4F;
break;
case 0xD9: //"U" variants
case 0xDA:
case 0xDB:
case 0xDC:
rxbyte = 0x55;
break;
case 0xDD: //"Y" acute -> "Y"
rxbyte = 0x59;
break;
/* case 0xDF: //beta //mucks up lcd1Smartie's degree symbol??
rxbyte = 0xE2;
break;
*/ case 0xE0: //"a" variants except umlaut
case 0xE1:
case 0xE2:
case 0xE3:
case 0xE5:
rxbyte = 0x61;
break;
case 0xE7: //"c" cedilla -> "c"
rxbyte = 0x63;
break;
case 0xE8: //"e" variants
case 0xE9:
case 0xEA:
case 0xEB:
rxbyte = 0x65;
break;
case 0xEC: //"i" variants
case 0xED:
case 0xEE:
case 0xEF:
rxbyte = 0x69;
break;
case 0xF2: //"o" variants except umlaut
case 0xF3:
case 0xF4:
case 0xF5:
case 0xF8:
rxbyte = 0x6F;
break;
case 0xF7: //division symbol
rxbyte = 0xFD;
break;
case 0xF9: //"u" variants except umlaut
case 0xFA:
case 0xFB:
rxbyte = 0x75;
break;
default:
break;
}
switch (controller)
{
case 1:
lcd1.write(rxbyte);
break;
case 2:
lcd2.write(rxbyte);
break;
}
return;
}
Re: 2x LCD arduino IC2 / Matrix.dll
Posted: April 29th, 2024, 9:46 am
by h3rm3s80
ITA:Buongiorno, questo è il codice modificato da me perfettamente funzionante per singolo LCD ma non funzionano contemporaneamente
ENG:Good morning, this is the code modified by me, perfectly working for single LCD but they don't work together
Code: Select all
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd2(0x23,16,2);
void setup()
{
lcd2.init(); // initialize the lcd
lcd2.backlight();
Serial.begin(9600);
}
byte serial_getch(){
int incoming;
while (Serial.available()==0){}
// read the incoming byte:
incoming = Serial.read();
return (byte) (incoming &0xff);
}
void loop(){
byte rxbyte;
byte temp;
byte col;
byte row;
rxbyte = serial_getch();
if (rxbyte == 254) //Matrix Orbital uses 254 prefix for commands
{
switch (serial_getch())
{
case 66: //backlight on (at previously set brightness)
// not implemented
break;
case 70: //backlight off
// not implemented
break;
case 71: //set cursor position
temp = (serial_getch() - 1); //get column byte
switch (serial_getch()) //get row byte
{
//line 1 is already set up
case 2:
temp += 0x40;
break;
case 3:
temp += 0x14;
break;
case 4:
temp += 0x54;
break;
default:
break;
}
lcd2.command(0b10000000 + temp);
break;
case 72: //cursor home (reset display position)
lcd2.command(2);
break;
case 74: //show underline cursor
lcd2.command(0b00001110);
break;
case 75: //underline cursor off
case 84: //block cursor off
lcd2.command(0b00001100);
break;
case 76: //move cursor left
lcd2.command(16);
break;
case 77: //move cursor right
lcd2.command(20);
break;
case 78: //define custom char
lcd2.command(64 + (serial_getch() * 8)); //get+set char address
for (temp = 7; temp != 0; temp--)
{
lcd2.write(serial_getch()); //get each pattern byte // change to lcd.write(serial_getch()) from lcd.print(serial_getch()) Arduino IDE 1+
}
break;
case 83: //show blinking block cursor
lcd2.command(0b00001111);
break;
case 86: //GPO OFF
//implement later
break;
case 87: //GPO ON
break;
case 88: //clear display, cursor home
lcd2.command(1);
break;
case 152: //set and remember (doesn't save value, though)
case 153: // Set backlight brightness (1 parameter, brightness)
break;
//these commands ignored (no parameters)
case 35: //read serial number
case 36: //read version number
case 55: //read module type
case 59: //exit flow-control mode
case 65: //auto transmit keypresses
case 96: //auto-repeat mode off (keypad)
case 67: //auto line-wrap on
case 68: //auto line-wrap off
case 81: //auto scroll on
case 82: //auto scroll off
case 104: //init horiz bar graph
case 109: //init med size digits
case 115: //init narrow vert bar graph
case 118: //init wide vert bar graph
break;
default:
//all other commands ignored and parameter byte discarded
temp = serial_getch(); //dump the command code
break;
}
return;
}
//END OF COMMAND HANDLER
//change accented char to plain, detect and change descenders
//NB descenders only work on 5x10 displays. This lookup table works
// with my DEM-20845 (Display Elektronik GmbH) LCD using KS0066 chip.
switch (rxbyte)
{
//chars that have direct equivalent in LCD charmap
case 0xE4: //ASCII "a" umlaut
rxbyte = 0xE1;
break;
case 0xF1: //ASCII "n" tilde
rxbyte = 0xEE;
break;
case 0xF6: //ASCII "o" umlaut
rxbyte = 0xEF; //was wrong in v0.86
break;
case 0xFC: //ASCII "u" umlaut
rxbyte = 0xF5;
break;
//accented -> plain equivalent
//and misc symbol translation
case 0xA3: //sterling (pounds)
rxbyte = 0xED;
break;
case 0xB5: //mu
rxbyte = 0xE4;
break;
case 0xC0: //"A" variants
case 0xC1:
case 0xC2:
case 0xC3:
case 0xC4:
case 0xC5:
rxbyte = 0x41;
break;
case 0xC8: //"E" variants
case 0xC9:
case 0xCA:
case 0xCB:
rxbyte = 0x45;
break;
case 0xCC: //"I" variants
case 0xCD:
case 0xCE:
case 0xCF:
rxbyte = 0x49;
break;
case 0xD1: //"N" tilde -> plain "N"
rxbyte = 0x43;
break;
case 0xD2: //"O" variants
case 0xD3:
case 0xD4:
case 0xD5:
case 0xD6:
case 0xD8:
rxbyte = 0x4F;
break;
case 0xD9: //"U" variants
case 0xDA:
case 0xDB:
case 0xDC:
rxbyte = 0x55;
break;
case 0xDD: //"Y" acute -> "Y"
rxbyte = 0x59;
break;
case 0xE0: //"a" variants except umlaut
case 0xE1:
case 0xE2:
case 0xE3:
case 0xE5:
rxbyte = 0x61;
break;
case 0xE7: //"c" cedilla -> "c"
rxbyte = 0x63;
break;
case 0xE8: //"e" variants
case 0xE9:
case 0xEA:
case 0xEB:
rxbyte = 0x65;
break;
case 0xEC: //"i" variants
case 0xED:
case 0xEE:
case 0xEF:
rxbyte = 0x69;
break;
case 0xF2: //"o" variants except umlaut
case 0xF3:
case 0xF4:
case 0xF5:
case 0xF8:
rxbyte = 0x6F;
break;
case 0xF7: //division symbol
rxbyte = 0xFD;
break;
case 0xF9: //"u" variants except umlaut
case 0xFA:
case 0xFB:
rxbyte = 0x75;
break;
default:
break;
}
lcd.command(0b10000000 + temp);
break;
case 72: //cursor home (reset display position)
lcd.command(2);
break;
case 74: //show underline cursor
lcd.command(0b00001110);
break;
case 75: //underline cursor off
case 84: //block cursor off
lcd.command(0b00001100);
break;
case 76: //move cursor left
lcd.command(16);
break;
case 77: //move cursor right
lcd.command(20);
break;
case 78: //define custom char
lcd.command(64 + (serial_getch() * 8)); //get+set char address
for (temp = 7; temp != 0; temp--)
{
lcd.write(serial_getch()); //get each pattern byte // change to lcd.write(serial_getch()) from lcd.print(serial_getch()) Arduino IDE 1+
}
break;
case 83: //show blinking block cursor
lcd.command(0b00001111);
break;
case 86: //GPO OFF
//implement later
break;
case 87: //GPO ON
/*temp = serial_getch();
if (temp == 1)
{
GPO1 = GPO_ON;
}
*/
break;
case 88: //clear display, cursor home
lcd.command(1);
break;
case 152: //set and remember (doesn't save value, though)
case 153: // Set backlight brightness (1 parameter, brightness)
break;
//these commands ignored (no parameters)
case 35: //read serial number
case 36: //read version number
case 55: //read module type
case 59: //exit flow-control mode
case 65: //auto transmit keypresses
case 96: //auto-repeat mode off (keypad)
case 67: //auto line-wrap on
case 68: //auto line-wrap off
case 81: //auto scroll on
case 82: //auto scroll off
case 104: //init horiz bar graph
case 109: //init med size digits
case 115: //init narrow vert bar graph
case 118: //init wide vert bar graph
break;
default:
//all other commands ignored and parameter byte discarded
temp = serial_getch(); //dump the command code
break;
}
return;
}
//END OF COMMAND HANDLER
//change accented char to plain, detect and change descenders
//NB descenders only work on 5x10 displays. This lookup table works
// with my DEM-20845 (Display Elektronik GmbH) LCD using KS0066 chip.
switch (rxbyte)
{
//chars that have direct equivalent in LCD charmap
/* case 0x67: //g
rxbyte = 0xE7;
break;
case 0x6A: //j
rxbyte = 0xEA;
break;
case 0x70: //p
rxbyte = 0xF0;
break;
case 0x71: //q
rxbyte = 0xF1;
break;
case 0x79: //y
rxbyte = 0xF9;
break;
*/
case 0xE4: //ASCII "a" umlaut
rxbyte = 0xE1;
break;
case 0xF1: //ASCII "n" tilde
rxbyte = 0xEE;
break;
case 0xF6: //ASCII "o" umlaut
rxbyte = 0xEF; //was wrong in v0.86
break;
case 0xFC: //ASCII "u" umlaut
rxbyte = 0xF5;
break;
//accented -> plain equivalent
//and misc symbol translation
case 0xA3: //sterling (pounds)
rxbyte = 0xED;
break;
/* case 0xB0: //degrees symbol
rxbyte = 0xDF;
break;
*/
case 0xB5: //mu
rxbyte = 0xE4;
break;
case 0xC0: //"A" variants
case 0xC1:
case 0xC2:
case 0xC3:
case 0xC4:
case 0xC5:
rxbyte = 0x41;
break;
case 0xC8: //"E" variants
case 0xC9:
case 0xCA:
case 0xCB:
rxbyte = 0x45;
break;
case 0xCC: //"I" variants
case 0xCD:
case 0xCE:
case 0xCF:
rxbyte = 0x49;
break;
case 0xD1: //"N" tilde -> plain "N"
rxbyte = 0x43;
break;
case 0xD2: //"O" variants
case 0xD3:
case 0xD4:
case 0xD5:
case 0xD6:
case 0xD8:
rxbyte = 0x4F;
break;
case 0xD9: //"U" variants
case 0xDA:
case 0xDB:
case 0xDC:
rxbyte = 0x55;
break;
case 0xDD: //"Y" acute -> "Y"
rxbyte = 0x59;
break;
/* case 0xDF: //beta //mucks up LCDSmartie's degree symbol??
rxbyte = 0xE2;
break;
*/
case 0xE0: //"a" variants except umlaut
case 0xE1:
case 0xE2:
case 0xE3:
case 0xE5:
rxbyte = 0x61;
break;
case 0xE7: //"c" cedilla -> "c"
rxbyte = 0x63;
break;
case 0xE8: //"e" variants
case 0xE9:
case 0xEA:
case 0xEB:
rxbyte = 0x65;
break;
case 0xEC: //"i" variants
case 0xED:
case 0xEE:
case 0xEF:
rxbyte = 0x69;
break;
case 0xF2: //"o" variants except umlaut
case 0xF3:
case 0xF4:
case 0xF5:
case 0xF8:
rxbyte = 0x6F;
break;
case 0xF7: //division symbol
rxbyte = 0xFD;
break;
case 0xF9: //"u" variants except umlaut
case 0xFA:
case 0xFB:
rxbyte = 0x75;
break;
default:
break;
}
lcd2.write(rxbyte); //otherwise a plain char so we print it to lcd, change to lcd.write(rxbyte) from lcd.print(rxbyte) Arduino IDE 1+
return;
lcd.write(rxbyte); //otherwise a plain char so we print it to lcd, change to lcd.write(rxbyte) from lcd.print(rxbyte) Arduino IDE 1+
return;
}
Re: 2x LCD arduino IC2 / Matrix.dll
Posted: April 29th, 2024, 9:52 am
by h3rm3s80
ITA:LCDSMARTIE dovrebbe comunicare ad arduino cosa scrivere su LCD1 e cosa su LCD2, ho provato varie soluzione di codice arduino, ma LCDSMARTIE scrive solo sul singolo display con nome "LCD", arduino non riesce ad unire virtualmente i due display, andrebbe gestito con DLL e nome LCD su cui scrivere da LCDSMARTIE
ENG:LCDSMARTIE should communicate to Arduino what to write on LCD1 and what on LCD2, I have tried various Arduino code solutions, but LCDSMARTIE only writes on the single display with the name "LCD", Arduino is unable to virtually join the two displays, it should be managed with DLL and LCD name to write to from LCDSMARTIE
Re: 2x LCD arduino IC2 / Matrix.dll
Posted: September 30th, 2024, 8:11 am
by h3rm3s80
ITA:Buongiorno, dopo un pò di tempo ho fatto qualche passo avanti con chatgpt, mi sono fatto correggere lo scketch varie volte ed ho inserito varie funzioni, ora mi trovo ad un punto morto, LCD SMARTIE con arduino invia dati ad entrambi gli LCD ma sono caratteri incomprensibili, numeri ed altro, che problema potrebbe essere?
ENG:Good morning, after some time I made some progress with chatgpt, I had the sketch corrected several times and I inserted various functions, now I find myself at a standstill, SMARTIE LCD with Arduino sends data to both LCDs but they are characters incomprehensible, numbers and more, what problem could it be?
Code: Select all
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Indirizzi I2C dei moduli LCD
LiquidCrystal_I2C lcd1(0x27, 20, 4); // Primo display
LiquidCrystal_I2C lcd2(0x23, 20, 4); // Secondo display
// Variabili per gestire la posizione del cursore
int cursor[2] = {0, 0}; // cursor[0] per lcd1, cursor[1] per lcd2
void setup() {
Serial.begin(115200);
// Inizializza i display
// lcd1.begin(20, 4);
// lcd2.begin(20, 4);
// Attiva il backlight
lcd1.init(); // initialize the lcd
lcd1.backlight();
lcd2.init(); // initialize the lcd
lcd2.backlight();
// Messaggio iniziale
lcd1.clear();
lcd1.setCursor(0, 0);
lcd1.print("**LCD SMARTIE**");
lcd2.clear();
lcd2.setCursor(0, 0);
lcd2.print("on Arduino");
}
byte serial_getch() {
while (Serial.available() == 0) {}
return Serial.read();
}
void loop() {
byte rxbyte = serial_getch();
// Controlla se il byte è un comando
if (rxbyte == 254) {
handleCommand();
return;
}
// Ignora il byte di controllo
if (rxbyte == 0xFF) {
return;
}
// Invia il carattere all'LCD
sendCharacterToDisplay(rxbyte);
}
void handleCommand() {
byte command = serial_getch();
switch (command) {
case 66: // backlight on
lcd1.backlight();
lcd2.backlight();
break;
case 70: // backlight off
lcd1.noBacklight();
lcd2.noBacklight();
break;
case 71: // set cursor position
setCursorPosition();
break;
case 88: // clear display, cursor home
clearDisplays();
break;
case 77: // Display message on both displays
displayLongMessage();
break;
default:
break;
}
}
void setCursorPosition() {
byte temp = serial_getch() - 1; // get column byte
byte row = serial_getch(); // get row byte
if (row == 1) {
cursor[0] = temp; // Aggiorna la posizione del cursore sul primo display
lcd1.setCursor(cursor[0], 0);
} else if (row == 2) {
cursor[1] = temp; // Aggiorna la posizione del cursore sul secondo display
lcd2.setCursor(cursor[1], 0);
}
}
void clearDisplays() {
lcd1.clear();
lcd2.clear();
cursor[0] = 0; // Resetta il cursore del primo display
cursor[1] = 0; // Resetta il cursore del secondo display
}
void sendCharacterToDisplay(byte character) {
if (cursor[0] < 20) {
lcd1.print(character); // Stampa sul primo display
cursor[0]++;
} else if (cursor[1] < 20) {
lcd2.print(character); // Stampa sul secondo display
cursor[1]++;
}
}
void displayLongMessage() {
String message = "This message is longer than 32 characters and will be split!";
clearDisplays(); // Resetta i cursori
for (int i = 0; i < message.length(); i++) {
if (i < 20) {
lcd1.setCursor(i, 0); // Prima riga del primo display
lcd1.print(message[i]);
} else {
lcd2.setCursor(i - 20, 0); // Prima riga del secondo display
lcd2.print(message[i]);
}
}
}