I'm trying to handle a string of Swedish characters to be displayed on an LCD I2C display (2x16).
It works if the entire text is sent to the display at the same time.
This is an example of that .:
But, I wish to be able to send character by character to the LCD display - like this .:
I have no idea how to handle that.
Is it possible with my hardware?
It works if the entire text is sent to the display at the same time.
This is an example of that .:
C-like:
// Version .: 22 dec 2019
// Shows .: åäö - ÅÄÖ - åäö on row2 in the LCD display
/*-----( Import needed libraries )-----*/
#include <Wire.h> // Comes with Arduino IDE
#include <LiquidCrystal_I2C.h>
/* -----( Declare Constants )----- */
byte AwithRing[8] = { //å
B00100,
B01010,
B01110,
B00001,
B01111,
B10001,
B01111,
};
byte AwithDots[8] = { //ä
B01010,
B00000,
B01110,
B00001,
B01111,
B10001,
B01111,
};
byte OwithDots[8] = { //ö
B01010,
B00000,
B01110,
B10001,
B10001,
B10001,
B01110,
};
byte BigAwithRing[8] = { //Å
0b00100,
0b01010,
0b01110,
0b10001,
0b11111,
0b10001,
0b10001,
0b00000
};
byte BigAwithDots[8] = { //Ä
0b01010,
0b00000,
0b01110,
0b10001,
0b11111,
0b10001,
0b10001,
0b00000
};
byte BigOwithDots[8] = { //Ö
0b01010,
0b01110,
0b10001,
0b10001,
0b10001,
0b10001,
0b01110,
0b00000
};
/* -----( Declare objects )----- */
// set the LCD address to 0x27 for a 16 chars 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
/*----( SETUP: RUNS ONCE )----*/
void setup() {
Serial.begin(115200); // Used to type in characters
lcd.init();
lcd.backlight();
//-------- Write characters on the display ------------------
lcd.createChar(1, AwithRing); //å
lcd.createChar(2, AwithDots); //ä
lcd.createChar(3, OwithDots); //ö
lcd.createChar(4, BigAwithRing); //Å
lcd.createChar(5, BigAwithDots); //Ä
lcd.createChar(6, BigOwithDots); //Ö
String message = "åäö - ÅÄÖ - öäå";
message.replace("å", "\1");
message.replace("ä", "\2");
message.replace("ö", "\3");
message.replace("Å", "\4");
message.replace("Ä", "\5");
message.replace("Ö", "\6");
lcd.setCursor(0, 1);
lcd.print(message);
} /*--(end setup )---*/
void loop() { /*----( LOOP: RUNS CONSTANTLY )----*/
}
But, I wish to be able to send character by character to the LCD display - like this .:
C-like:
/* I2C LCD with Arduino example code. More info: https://www.makerguides.com
https://www.makerguides.com/character-i2c-lcd-arduino-tutorial/ */
// Include the libraries:
// LiquidCrystal_I2C.h: https://github.com/johnrickman/LiquidCrystal_I2C
#include <Wire.h> // Library for I2C communication
#include <LiquidCrystal_I2C.h> // Library for LCD
// Wiring: SDA pin is connected to A4 and SCL pin to A5.
// Connect to LCD via I2C, default address 0x27 (A0-A2 not jumpered)
// LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 20, 4); // Change to (0x27,16,2) for 16x2 LCD.
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2);
byte AwithRing[8] = { //å
B00100,
B01010,
B01110,
B00001,
B01111,
B10001,
B01111,
};
byte AwithDots[8] = { //ä
B01010,
B00000,
B01110,
B00001,
B01111,
B10001,
B01111,
};
byte OwithDots[8] = { //ö
B01010,
B00000,
B01110,
B10001,
B10001,
B10001,
B01110,
};
byte BigAwithRing[8] = { //Å
0b00100,
0b01010,
0b01110,
0b10001,
0b11111,
0b10001,
0b10001,
0b00000
};
byte BigAwithDots[8] = { //Ä
0b01010,
0b00000,
0b01110,
0b10001,
0b11111,
0b10001,
0b10001,
0b00000
};
byte BigOwithDots[8] = { //Ö
0b01010,
0b01110,
0b10001,
0b10001,
0b10001,
0b10001,
0b01110,
0b00000
};
char TextLCD[16] = "å -What I want!";
void setup() {
lcd.init(); // Initiate the LCD:
lcd.backlight(); // Backlight ON:
lcd.createChar(1, AwithRing); //å
lcd.createChar(2, AwithDots); //ä
lcd.createChar(3, OwithDots); //ö
lcd.createChar(4, BigAwithRing); //Å
lcd.createChar(5, BigAwithDots); //Ä
lcd.createChar(6, BigOwithDots); //Ö
}
void loop() {
i = 0;
while (i < strlen(TextLCD))
{ lcd.setCursor(i, 0); // Pekare på .: Kolumn1 - Rad1
char pointer = TextLCD[i++];
if ( pointer == 'å' ) {
pointer = 1;
}
lcd.print(pointer);
delay(500);
}
delay(1000);
lcd.clear();
}
Is it possible with my hardware?