Jag vill kunna skriva åäö på en 1602 display med I2C
Jag gör en replace på åäö och ersätter dom med createchar, och det fungerar bra förutom att jag inte får bort det konstiga tecknet före åäö, se bild.
På displayens rad 1 visas hur det blir om jag skriver å ä ö
På displayens rad 2 visas hur det blir när jag har gjort en replace med egna tecken.
Någon som har förslag på åtgärd?
/* YourDuino.com Example Software Sketch
16 character 2 line I2C Display
Backpack Interface labelled "YwRobot Arduino LCM1602 IIC V1"
terry@yourduino.com */
/-----( Import needed libraries )-----/
#include <Wire.h> // Comes with Arduino IDE
// Get the LCD I2C Library here:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
#include <LiquidCrystal_I2C.h>
/-----( Declare Constants )-----/
/-----( Declare objects )-----/
// set the LCD address to 0x27 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
void setup() /----( SETUP: RUNS ONCE )----/
{
Serial.begin(9600); // Used to type in characters
lcd.begin(16,2); // initialize the lcd for 16 chars 2 lines, turn on backlight
// ------- backlight -------------
{
lcd.backlight();
}
//-------- Write characters on the display ------------------
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,
};
lcd.createChar(1, AwithRing);
lcd.createChar(2, AwithDots);
lcd.createChar(3, OwithDots);
// Display. (Set Serial Monitor option to "No Line Ending")
lcd.clear();
lcd.setCursor(0,0);
lcd.print("å ä ö");
lcd.setCursor(0,1);
String message = "å ä ö";
message.replace('å', char(1));
message.replace('ä', byte(2));
message.replace('ö', byte(3));
lcd.print(message);
}/--(end setup )---/
void loop() /----( LOOP: RUNS CONSTANTLY )----/
{
}