//-------------------------------------- //author:Victor Chen //web :www.vic8051.com //參考資料:Arduino實作入門與應用 ----台灣/松崗 //-------------------------------------- //字型資料設計 byte LCD_PAT[]= {0x04, 0x08, 0x1F, 0x01, 0x01, 0x09, 0x06, 0x00}; byte LCD_PAT1[]={0x0A, 0x0B, 0x3C, 0x09, 0x09, 0x0B, 0x0C, 0x0B}; byte LCD_PAT2[]={0x10, 0x1f, 0x02, 0x0f, 0x0a, 0x1f, 0x02, 0x00}; byte LCD_PAT3[]={0x33, 0x0B, 0x3C, 0x05, 0x09, 0x07, 0x09, 0x08}; byte LCD_PAT4[]={0x0B, 0x0A, 0x3C, 0x01, 0x01, 0x04, 0x03, 0x02}; byte LCD_PAT5[]={0x0C, 0x0B, 0x3A, 0x03, 0x02, 0x04, 0x0C, 0x0B}; byte LCD_PAT6[]={0x0D, 0x0C, 0x3B, 0x05, 0x03, 0x05, 0x03, 0x02}; byte LCD_PAT7[]={0x0A, 0x0D, 0x3C, 0x07, 0x04, 0x05, 0x0C, 0x0B}; #include //引用LCD程式庫 LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //設定 LCD 腳位 void setup() { //初始化設定 lcd.begin(16, 2); lcd.print("hello, world1"); //填入特殊字型資料 lcd.createChar(0, LCD_PAT); lcd.createChar(1, LCD_PAT1); lcd.createChar(2, LCD_PAT2); lcd.createChar(3, LCD_PAT3); lcd.createChar(4, LCD_PAT4); lcd.createChar(5, LCD_PAT5); lcd.createChar(6, LCD_PAT6); lcd.createChar(7, LCD_PAT7); } //----------------------------------- void loop()//主程式迴圈 { int i; lcd.setCursor(0, 0); //設定游標於第一列起始位置 lcd.print("LCD pat......"); lcd.setCursor(0, 1); //設定游標於第二列起始位置 for(i=0; i<8; i++) lcd.write(i); //顯示特殊字型 while(1); // 無窮迴圈 }