createChar()
Description
自訂客製化的字元,最多可以自訂八個 5*8 的字元,每個自訂字元會有一個編號,編號從 0 ~ 7。每個自訂字元使用一個內含有 8 個位元組的陣列來儲存,其中每個位元組只會使用到 0 ~ 4 五個位元,如果在這 0 ~ 4 的位元設定為 1 代表要液晶顯示器的這格亮,如果設定為 0 則代表要暗。要顯示自訂字元時把自訂字元的編號作為參數傳入 write()
函式。
註:當要使用編號為 0 的自訂字元時,如果作為參數給 write()
函式的不是變數,應該要把型態轉換為 byte
,否則會發生編譯錯誤,詳見以下範例。
語法
lcd.createChar(num, data)
參數
num
:自訂字元的編號
data
:存放自訂字元的陣列
範例
#include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); byte smiley[8] = { B00000, B10001, B00000, B00000, B10001, B01110, B00000, }; void setup() { lcd.createChar(0, smiley); lcd.begin(16, 2); lcd.write(byte(0)); } void loop() {}
The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.