感謝王老師給我取中文字模的工具
可以自定義的字元共有8個,16 點字上下要 2 層
所以一次只能跑 4 個字的寬度
1 個字寬度 16 ,要跨 3 個 5*8 的自定義字
#include <Wire.h>// Comes with Arduino IDE
#include <LiquidCrystal_I2C.h>
int cpoint=0;
byte a[20][8] = {{B00000,B00000,B00111,B00000,B00000,B00000,B00000,B00000},
{B00000,B00000,B11111,B00010,B00010,B00010,B00010,B00010},
{B00000,B00010,B11111,B00000,B00000,B00000,B00000,B00100},
{B00000,B00001,B00001,B00001,B00111,B00001,B00001,B00001},
{B00000,B10010,B00011,B00010,B11010,B00010,B00010,B01010},
{B00000,B00000,B11111,B00000,B00001,B11111,B00000,B00000},
{B00000,B10000,B11000,B00000,B00000,B10000,B00000,B00000},
{B00000,B01100,B01000,B01000,B01000,B01000,B01000,B01000},
{B00000,B01100,B01000,B01000,B01000,B01000,B01000,B01000},
{B00000,B01100,B01000,B01000,B01000,B01000,B01000,B01000},
{B00011,B00000,B00000,B00000,B00000,B00000,B01111,B00000},
{B11111,B00010,B00010,B00010,B00010,B00010,B11111,B00000},
{B11110,B00000,B00000,B00000,B00000,B00001,B11111,B00000},
{B00001,B00111,B00101,B00001,B00001,B00001,B10111,B00010},
{B10011,B00010,B00010,B00010,B00010,B00100,B00100,B01000},
{B11111,B10010,B10010,B10010,B10001,B10101,B11000,B10000},
{B11000,B00000,B11000,B10000,B00000,B00001,B10001,B01010},
{B01000,B01000,B10000,B10000,B10000,B00000,B00000,B00000},
{B01000,B01000,B01000,B01000,B01000,B01000,B00000,B00000},
{B01000,B01000,B01000,B01000,B01000,B01000,B01000,B01000}};
// 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(){
bgBlink();
lcd.clear();
lcd.backlight();
lcd.setCursor(0,0);
}
void bgBlink(){
lcd.begin(16,2);// initialize the lcd for 20 chars 4 lines and turn on backlight
for(int i = 0; i< 3; i++){
lcd.backlight();
delay(250);
lcd.noBacklight();
delay(250);
}
}
void loop(){
lcd.clear();
for(int n=0;n<4;n++){
if(n+cpoint<10){
lcd.createChar (n, a[n+cpoint]); // load smiley to memory 0
}else{
lcd.createChar (n, a[n+cpoint-10]); // load smiley to memory 0
}
}
lcd.setCursor(0,0);
for(int a=0;a<4;a++){
lcd.print(char(a));
}
for(int n=0;n<4;n++){
if(n+cpoint+10<20){
lcd.createChar (n+4, a[n+cpoint+10]); // load smiley to memory 0
}else{
lcd.createChar (n+4, a[n+cpoint]); // load smiley to memory 0
}
}
lcd.setCursor(0,1);
for(int a=0;a<4;a++){
lcd.print(char(a+4));
}
if(cpoint==9){
cpoint=0;
}else{
cpoint++;
}
delay(1000);
}