物聯網系列 : 單色圖形顯示介紹 (NOKIA 5110 LCD 開發篇 ) 2016 年 8 月 15 日八月, 2016 文 \ 曹永忠 本篇是接續上篇文章 物聯網系列 : 單色圖形顯示介紹 (NOKIA 5110 LCD 基本篇 ), 已經可以讓 Nokia 5110 LCD 模組顯示字形 ( 曹永忠, 2016d), 畫出基本的幾何圖形, 甚至是簡單的動畫, 但是這些例子並不容易, 所以本文要教讀者如何顯示文字 如何放大文字 畫出幾合圖形, 對一般讀者仍不太容易理解 所以本文告訴讀者, 如何使用 Nokia 5110 LCD 模組的函式庫, 來顯示字形, 如何放大文字 顯示圖片, 甚至簡單的動畫等等即為本文開發篇的主要內容 模組電路組立 NOKIA 5110 是一款基於圖形顯示的 LCD 螢幕 ( 如下圖所示 ), 主要這款螢幕, 被手機大廠 NOKIA 用來裝置在 5110 系列手機, 因而大受歡迎並且有很多的應用 Nokia 5110 LCD 使用的 PCD8544 控制器,NOKIA 3110 用的也是這款控制器, PCD8554 是一款低功耗的 CMOS LCD 控制器, 用於驅動 48 行 84 列的圖形顯示, 並且採用串列匯流排界面與微控制器相連, 大大減少了週邊控制線的數量, 在使用時十分的方便, 而且相對於 LCD1602 LCD12864 都有著自己的獨特優勢
圖 1 Nokia 5110 LCD 模組 在 Arduino 官網 :http://playground.arduino.cc/code/pcd8544, 也有介介紹 Nokia 5110 LCD 模組, 讀者者可以參考考下表之腳位位說明, 進進行電路組立 Nokia 5110 接腳 VCC GND SCE/CE RST/Reset D/C DN/MOSI SCLK LED 表 1 Nokia 5110 LCD 接腳說明 5V( 正 ) 接地晶片致能晶片重置 Data/Comma and select 資料 / 命令選選擇 Serial Data Out 資料輸出 Serial Clockk Out 脈波控制輸輸出被光電源 LCD 模組接接腳表開發版腳位 +5C GND D7 D6 D5 D4 D3 用途供電 ( 正 ) 供電 ( 接地 ) 數位腳位 7 數位腳位 6 數位腳位 5 數位腳位 4 數位腳位 3 +3.3V 3.3V 供電 ( 正 )
Nokia 5110 LCD 開發版 顯示文字 首先, 我們要教讀者者在 Nokia 5110 LCD 模組顯示文文字, 首先先我們依上面面電路組組立將 Nokia 5110 LCD 模組與開開發版連接接完成, 再進進行程式寫寫作 本程式需需要用到兩個個函式庫 ( 曹永忠, 2016e), 關於 Adafruit_PCD8544.h, 請到到網址 : https://github.com/brucetsao/lib_for_mcu/tree/master/arduino_lib/libraries/adafr uit-pcd8544-nokia-5110 或 https://learn.adafruit.com/nokia-5110-3310-monochrome-lcd/graphics-library 或 https://github.com/adafruit/adafruit-pcd8544-nokia-5110-lcd-library, 進行下載,
關於 Adafruit_GFX.h, 請到網址 : https://github.com/brucetsao/lib_for_mcu/tree/master/arduino_lib/libr aries/adafruit_gfx, 進行下載 我們, 請讀者鍵入 Sketch IDE 軟體 ( 軟體下載請到 : https://www.arduino.cc/en/main/software), 編譯完成後上傳到開發版進行測試 表 2 Nokia 5110 LCD 模組文字測試程式一 Nokia 5110 LCD 模組文字測試程式一 (NOKIA_Text_Show) /******************************************************************** * This is an example sketch for our Monochrome Nokia 5110 LCD Displays Pick one up today in the adafruit shop! ------> http://www.adafruit.com/products/338 These displays use SPI to communicate, 4 or 5 pins are required to interface Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, check license.txt for more information All text above, and the splash screen must be included in any redistribution ********************************************************************* / #include <SPI.h> #include <Adafruit_GFX.h> #include <Adafruit_PCD8544.h> #define PIN_SCE 7 #define PIN_RESET 6
#define PIN_DC 5 #define PIN_SDIN 4 #define PIN_SCLK 3 // Software SPI (slower updates, more flexible pin options): //=== old version pin out====== // pin 7 - Serial clock out (SCLK) // pin 6 - Serial data out (DIN) // pin 5 - Data/Command select (D/C) // pin 4 - LCD chip select (CS) // pin 3 - LCD reset (RST) Adafruit_PCD8544 display = Adafruit_PCD8544(PIN_SCLK, PIN_SDIN, PIN_DC, PIN_SCE, PIN_RESET); // Adafruit_PCD8544 display = Adafruit_PCD8544(SCLK, DIN, D/C, CS/SCE, RST); #define NUMFLAKES 10 #define XPOS 0 #define YPOS 1 #define DELTAY 2 void setup() { // put your setup code here, to run once: Serial.begin(9600); display.begin(); // init done //init Nokia 5110 display // you can change the contrast around to adapt the display // for the best viewing! display.setcontrast(50); //set Contrast display.cleardisplay(); // 清除螢幕 display.display(); // show splashscreen // display.settextsize(1); // 設定字形大小 display.settextcolor(black); // 設定字形顏色黑色 display.setcursor(0,0); // 位置歸零
display.println("hello, world!"); // 印出字 display.settextcolor(white, BLACK); // 反白文字 display.println(3.141592); // 印出字 display.settextsize(2); // 設定字形大小 display.settextcolor(black); // 設定字形顏色黑色 display.print("0x"); display.println(0xdeadbeef, HEX); // 印出字 display.display(); // 顯示所有上面內容, 必要在所有秀字命令後, 一定要的 delay(2000); void loop() { // put your main code here, to run repeatedly: 程式下載網址 : https://github.com/brucetsao/makerdiwo/tree/master/201608 如下圖所示, 我們可以看到 Nokia 5110 LCD 模組資訊顯示出來文字 ( 曹永忠, 2016a, 2016b, 2016c, 2016d; 曹永忠, 許智誠, & 蔡英德, 2015a, 2015b, 2015c, 2015d, 2015e, 2015f; 曹永忠, 許碩芳, 許智誠, & 蔡英德, 2015a, 2015b)
圖 2 Nokia 5110 LCD 模組文字測試程式一結果畫面 顯示點幾何圖形 首先, 我們要教讀者在 Nokia 5110 LCD 模組畫出許多點, 首先我們依上面電路組立將 Nokia 5110 LCD 模組與開發版連接完成, 再進行程式寫作 本程式需要用到兩個函式庫 ( 曹永忠, 2016e), 關於 Adafruit_PCD8544.h, 請到網址 : https://github.com/brucetsao/lib_for_mcu/tree/master/arduino_lib/libraries/adafr uit-pcd8544-nokia-5110 或 https://learn.adafruit.com/nokia-5110-3310-monochrome-lcd/graphics-library 或 https://github.com/adafruit/adafruit-pcd8544-nokia-5110-lcd-library, 進行下載, 關於 Adafruit_GFX.h, 請到網址 : https://github.com/brucetsao/lib_for_mcu/tree/master/arduino_lib/libr aries/adafruit_gfx, 進行下載 我們, 請讀者鍵入 Sketch IDE 軟體 ( 軟體下載請到 : https://www.arduino.cc/en/main/software), 編譯完成後上傳到開發版進行測
試 表 3 Nokia 5110 LCD 模組畫點測試程式一 N Nokia 5110 LCD 模組畫點測試程式一 (NOKIA_drawpixel) /******************************************************************** * This is an example sketch for our Monochrome Nokia 5110 LCD Displays Pick one up today in the adafruit shop! ------> http://www.adafruit.com/products/338 These displays use SPI to communicate, 4 or 5 pins are required to interface Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, check license.txt for more information All text above, and the splash screen must be included in any redistribution ********************************************************************* / #include <SPI.h> #include <Adafruit_GFX.h> #include <Adafruit_PCD8544.h> #define PIN_SCE 7 #define PIN_RESET 6 #define PIN_DC 5 #define PIN_SDIN 4 #define PIN_SCLK 3 // Software SPI (slower updates, more flexible pin options): //=== old version pin out====== // pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN) // pin 5 - Data/Command select (D/C) // pin 4 - LCD chip select (CS) // pin 3 - LCD reset (RST) Adafruit_PCD8544 display = Adafruit_PCD8544(PIN_SCLK, PIN_SDIN, PIN_DC, PIN_SCE, PIN_RESET); // Adafruit_PCD8544 display = Adafruit_PCD8544(SCLK, DIN, D/C, CS/SCE, RST); #define NUMFLAKES 10 #define XPOS 0 #define YPOS 1 #define DELTAY 2 void setup() { // put your setup code here, to run once: Serial.begin(9600); display.begin(); // init done //init Nokia 5110 display // you can change the contrast around to adapt the display // for the best viewing! display.setcontrast(50); //set Contrast display.cleardisplay(); // 清除螢幕 display.display(); // show splashscreen // // draw a single pixel display.drawpixel(10, 10, BLACK); display.drawpixel(10, 12, BLACK); display.drawpixel(10, 14, BLACK); display.drawpixel(10, 16, BLACK); display.drawpixel(10, 18, BLACK); display.drawpixel(10, 20, BLACK); display.drawpixel(14, 10, BLACK); display.drawpixel(14, 12, BLACK); display.drawpixel(14, 14, BLACK);
display.drawpixel(14, 16, BLACK); display.drawpixel(14, 18, BLACK); display.drawpixel(14, 20, BLACK); display.drawpixel(18, 10, BLACK); display.drawpixel(18, 12, BLACK); display.drawpixel(18, 14, BLACK); display.drawpixel(18, 16, BLACK); display.drawpixel(18, 18, BLACK); display.drawpixel(18, 20, BLACK); display.drawpixel(22, 10, BLACK); display.drawpixel(22, 12, BLACK); display.drawpixel(22, 14, BLACK); display.drawpixel(22, 16, BLACK); display.drawpixel(22, 18, BLACK); display.drawpixel(22, 20, BLACK); display.display(); // 顯示所有上面內容, 必要在所有秀字命令後, 一定要的 delay(2000); void loop() { // put your main code here, to run repeatedly: 程式下載網址 : https://github.com/brucetsao/makerdiwo/tree/master/201608 如下圖所示, 我們可以看到 Nokia 5110 LCD 模組畫出許多點 ( 曹永忠, 2016a, 2016b, 2016c, 2016d; 曹永忠, 許智誠, et al., 2015a, 2015b, 2015c, 2015d, 2015e, 2015f; 曹永忠, 許碩芳, et al., 2015a, 2015b)
圖 3 Nokia 5110 LCD 模組畫點測試程式一結果畫面 顯示線幾何圖形 首先, 我們要教讀者在 Nokia 5110 LCD 模組畫出線, 首先我們依上面電路組立將 Nokia 5110 LCD 模組與開發版連接完成, 再進行程式寫作 本程式需要用到兩個函式庫 ( 曹永忠, 2016e), 關於 Adafruit_PCD8544.h, 請到網址 : https://github.com/brucetsao/lib_for_mcu/tree/master/arduino_lib/libraries/adafr uit-pcd8544-nokia-5110 或 https://learn.adafruit.com/nokia-5110-3310-monochrome-lcd/graphics-library 或 https://github.com/adafruit/adafruit-pcd8544-nokia-5110-lcd-library, 進行下載, 關於 Adafruit_GFX.h, 請到網址 : https://github.com/brucetsao/lib_for_mcu/tree/master/arduino_lib/libr aries/adafruit_gfx, 進行下載 我們, 請讀者鍵入 Sketch IDE 軟體 ( 軟體下載請到 : https://www.arduino.cc/en/main/software), 編譯完成後上傳到開發版進行測
試 表 4 Nokia 5110 LCD 模組畫線測試程式一 Nokia 5110 LCD 模組畫線測試程式一 (NOKIA_Text_Show) /******************************************************************** * This is an example sketch for our Monochrome Nokia 5110 LCD Displays Pick one up today in the adafruit shop! ------> http://www.adafruit.com/products/338 These displays use SPI to communicate, 4 or 5 pins are required to interface Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, check license.txt for more information All text above, and the splash screen must be included in any redistribution ********************************************************************* / #include <SPI.h> #include <Adafruit_GFX.h> #include <Adafruit_PCD8544.h> #define PIN_SCE 7 #define PIN_RESET 6 #define PIN_DC 5 #define PIN_SDIN 4 #define PIN_SCLK 3 // Software SPI (slower updates, more flexible pin options): //=== old version pin out====== // pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN) // pin 5 - Data/Command select (D/C) // pin 4 - LCD chip select (CS) // pin 3 - LCD reset (RST) Adafruit_PCD8544 display = Adafruit_PCD8544(PIN_SCLK, PIN_SDIN, PIN_DC, PIN_SCE, PIN_RESET); // Adafruit_PCD8544 display = Adafruit_PCD8544(SCLK, DIN, D/C, CS/SCE, RST); #define NUMFLAKES 10 #define XPOS 0 #define YPOS 1 #define DELTAY 2 void setup() { // put your setup code here, to run once: Serial.begin(9600); display.begin(); // init done //init Nokia 5110 display // you can change the contrast around to adapt the display // for the best viewing! display.setcontrast(50); //set Contrast display.cleardisplay(); // 清除螢幕 display.display(); // show splashscreen // // draw a single line for (int16_t i=0; i<display.width(); i+=4) { display.drawline(0, 0, i, display.height()-1, BLACK); display.display(); for (int16_t i=0; i<display.height(); i+=4) { display.drawline(0, 0, display.width()-1, i, BLACK); display.display();
display.display(); 要的 delay(2000); // 顯示所有上面內容, 必要在所有秀字命令後, 一定 void loop() { // put your main code here, to run repeatedly: 程式下載網址 : https://github.com/brucetsao/makerdiwo/tree/master/201608 如下圖所示, 我們可以看到 Nokia 5110 LCD 模組資畫出許多線 ( 曹永忠, 2016a, 2016b, 2016c, 2016d; 曹永忠, 許智誠, et al., 2015a, 2015b, 2015c, 2015d, 2015e, 2015f; 曹永忠, 許碩芳, et al., 2015a, 2015b) 圖 4 Nokia 5110 LCD 模組畫線測試程式一結果畫面
顯示矩形幾何形狀 首先, 我們要教讀者在 Nokia 5110 LCD 模組畫出幾何圖形 : 矩形, 首先我們依上面電路組立將 Nokia 5110 LCD 模組與開發版連接完成, 再進行程式寫作 本程式需要用到兩個函式庫 ( 曹永忠, 2016e), 關於 Adafruit_PCD8544.h, 請到網址 : https://github.com/brucetsao/lib_for_mcu/tree/master/arduino_lib/libraries/adafr uit-pcd8544-nokia-5110 或 https://learn.adafruit.com/nokia-5110-3310-monochrome-lcd/graphics-library 或 https://github.com/adafruit/adafruit-pcd8544-nokia-5110-lcd-library, 進行下載, 關於 Adafruit_GFX.h, 請到網址 : https://github.com/brucetsao/lib_for_mcu/tree/master/arduino_lib/libr aries/adafruit_gfx, 進行下載 我們, 請讀者鍵入 Sketch IDE 軟體 ( 軟體下載請到 : https://www.arduino.cc/en/main/software), 編譯完成後上傳到開發版進行測試 表 5 Nokia 5110 LCD 模組矩形幾何形狀測試程式一 Nokia 5110 LCD 模組矩形幾何形狀測試程式一 (NOKIA_drawGEO) /******************************************************************** * This is an example sketch for our Monochrome Nokia 5110 LCD Displays Pick one up today in the adafruit shop! ------> http://www.adafruit.com/products/338 These displays use SPI to communicate, 4 or 5 pins are required to interface Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing
products from Adafruit! Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, check license.txt for more information All text above, and the splash screen must be included in any redistribution ********************************************************************* / #include <SPI.h> #include <Adafruit_GFX.h> #include <Adafruit_PCD8544.h> #define PIN_SCE 7 #define PIN_RESET 6 #define PIN_DC 5 #define PIN_SDIN 4 #define PIN_SCLK 3 // Software SPI (slower updates, more flexible pin options): //=== old version pin out====== // pin 7 - Serial clock out (SCLK) // pin 6 - Serial data out (DIN) // pin 5 - Data/Command select (D/C) // pin 4 - LCD chip select (CS) // pin 3 - LCD reset (RST) Adafruit_PCD8544 display = Adafruit_PCD8544(PIN_SCLK, PIN_SDIN, PIN_DC, PIN_SCE, PIN_RESET); // Adafruit_PCD8544 display = Adafruit_PCD8544(SCLK, DIN, D/C, CS/SCE, RST); #define NUMFLAKES 10 #define XPOS 0 #define YPOS 1 #define DELTAY 2 void setup() { // put your setup code here, to run once:
Serial.begin(9600); display.begin(); // init done //init Nokia 5110 display // you can change the contrast around to adapt the display // for the best viewing! display.setcontrast(50); //set Contrast display.cleardisplay(); // 清除螢幕 display.display(); // show splashscreen // // draw a 多個矩形 for (int16_t i=0; i<display.height()/2; i+=2) { display.drawrect(i, i, display.width()-2*i, display.height()-2*i, BLACK); display.display(); display.display(); 要的 delay(2000); // 顯示所有上面內容, 必要在所有秀字命令後, 一定 void loop() { // put your main code here, to run repeatedly: 程式下載網址 : https://github.com/brucetsao/makerdiwo/tree/master/201608 如下圖所示, 我們可以看到 Nokia 5110 LCD 模組畫出幾何圖形 : 矩形 ( 曹永忠, 2016a, 2016b, 2016c, 2016d; 曹永忠, 許智誠, et al., 2015a, 2015b, 2015c, 2015d, 2015e, 2015f; 曹永忠, 許碩芳, et al., 2015a, 2015b)
圖 5 Nokia 5110 LCD 模組矩形幾何形狀測試程式一結果畫面 顯示圓形幾何形狀 首先, 我們要教讀者在 Nokia 5110 LCD 模組畫出幾何圖形 : 圓形, 首先我們依上面電路組立將 Nokia 5110 LCD 模組與開發版連接完成, 再進行程式寫作 本程式需要用到兩個函式庫 ( 曹永忠, 2016e), 關於 Adafruit_PCD8544.h, 請到網址 : https://github.com/brucetsao/lib_for_mcu/tree/master/arduino_lib/libraries/adafr uit-pcd8544-nokia-5110 或 https://learn.adafruit.com/nokia-5110-3310-monochrome-lcd/graphics-library 或 https://github.com/adafruit/adafruit-pcd8544-nokia-5110-lcd-library, 進行下載, 關於 Adafruit_GFX.h, 請到網址 : https://github.com/brucetsao/lib_for_mcu/tree/master/arduino_lib/libr aries/adafruit_gfx, 進行下載 我們, 請讀者鍵入 Sketch IDE 軟體 ( 軟體下載請到 : https://www.arduino.cc/en/main/software), 編譯完成後上傳到開發版進行測
試 表 6 Nokia 5110 LCD 模組圓形幾何形狀測試程式一 Nokia 5110 LCD 模組圓形幾何形狀測試程式一 (NOKIA_drawGEO1) /******************************************************************** * This is an example sketch for our Monochrome Nokia 5110 LCD Displays Pick one up today in the adafruit shop! ------> http://www.adafruit.com/products/338 These displays use SPI to communicate, 4 or 5 pins are required to interface Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, check license.txt for more information All text above, and the splash screen must be included in any redistribution ********************************************************************* / #include <SPI.h> #include <Adafruit_GFX.h> #include <Adafruit_PCD8544.h> #define PIN_SCE 7 #define PIN_RESET 6 #define PIN_DC 5 #define PIN_SDIN 4 #define PIN_SCLK 3 // Software SPI (slower updates, more flexible pin options): //=== old version pin out====== // pin 7 - Serial clock out (SCLK)
// pin 6 - Serial data out (DIN) // pin 5 - Data/Command select (D/C) // pin 4 - LCD chip select (CS) // pin 3 - LCD reset (RST) Adafruit_PCD8544 display = Adafruit_PCD8544(PIN_SCLK, PIN_SDIN, PIN_DC, PIN_SCE, PIN_RESET); // Adafruit_PCD8544 display = Adafruit_PCD8544(SCLK, DIN, D/C, CS/SCE, RST); #define NUMFLAKES 10 #define XPOS 0 #define YPOS 1 #define DELTAY 2 void setup() { // put your setup code here, to run once: Serial.begin(9600); display.begin(); // init done //init Nokia 5110 display // you can change the contrast around to adapt the display // for the best viewing! display.setcontrast(50); //set Contrast display.cleardisplay(); // 清除螢幕 display.display(); // show splashscreen // // draw a 多個矩形 for (int16_t i=0; i<display.height(); i+=6) { display.drawcircle(display.width()/2, display.height()/2, i/2, BLACK); display.display(); display.display(); 要的 delay(2000); // 顯示所有上面內容, 必要在所有秀字命令後, 一定
void loop() { // put your main code here, to run repeatedly: 程式下載網址 : https://github.com/brucetsao/makerdiwo/tree/master/201608 如下圖所示, 我們可以看到 Nokia 5110 LCD 模組畫出幾何圖形 : 圓形形狀 ( 曹永忠, 2016a, 2016b, 2016c, 2016d; 曹永忠, 許智誠, et al., 2015a, 2015b, 2015c, 2015d, 2015e, 2015f; 曹永忠, 許碩芳, et al., 2015a, 2015b) 圖 6 Nokia 5110 LCD 模組圓形幾何形狀測試程式一結果畫面
顯示三角形幾何形狀 首先, 我們要教讀者在 Nokia 5110 LCD 模組畫出幾何圖形 : 三角形幾何形狀, 首先我們依上面電路組立將 Nokia 5110 LCD 模組與開發版連接完成, 再進行程式寫作 本程式需要用到兩個函式庫 ( 曹永忠, 2016e), 關於 Adafruit_PCD8544.h, 請到網址 : https://github.com/brucetsao/lib_for_mcu/tree/master/arduino_lib/libraries/adafr uit-pcd8544-nokia-5110 或 https://learn.adafruit.com/nokia-5110-3310-monochrome-lcd/graphics-library 或 https://github.com/adafruit/adafruit-pcd8544-nokia-5110-lcd-library, 進行下載, 關於 Adafruit_GFX.h, 請到網址 : https://github.com/brucetsao/lib_for_mcu/tree/master/arduino_lib/libr aries/adafruit_gfx, 進行下載 我們, 請讀者鍵入 Sketch IDE 軟體 ( 軟體下載請到 : https://www.arduino.cc/en/main/software), 編譯完成後上傳到開發版進行測試 表 7 Nokia 5110 LCD 模組畫三角形幾何形狀測試程式一 Nokia 5110 LCD 模組畫三角形幾何形狀測試程式一 (NOKIA_drawGEO2) /******************************************************************** * This is an example sketch for our Monochrome Nokia 5110 LCD Displays Pick one up today in the adafruit shop! ------> http://www.adafruit.com/products/338 These displays use SPI to communicate, 4 or 5 pins are required to interface Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, check license.txt for more information All text above, and the splash screen must be included in any redistribution ********************************************************************* / #include <SPI.h> #include <Adafruit_GFX.h> #include <Adafruit_PCD8544.h> #define PIN_SCE 7 #define PIN_RESET 6 #define PIN_DC 5 #define PIN_SDIN 4 #define PIN_SCLK 3 // Software SPI (slower updates, more flexible pin options): //=== old version pin out====== // pin 7 - Serial clock out (SCLK) // pin 6 - Serial data out (DIN) // pin 5 - Data/Command select (D/C) // pin 4 - LCD chip select (CS) // pin 3 - LCD reset (RST) Adafruit_PCD8544 display = Adafruit_PCD8544(PIN_SCLK, PIN_SDIN, PIN_DC, PIN_SCE, PIN_RESET); // Adafruit_PCD8544 display = Adafruit_PCD8544(SCLK, DIN, D/C, CS/SCE, RST); #define NUMFLAKES 10 #define XPOS 0 #define YPOS 1 #define DELTAY 2 void setup() { // put your setup code here, to run once: Serial.begin(9600);
display.begin(); // init done //init Nokia 5110 display // you can change the contrast around to adapt the display // for the best viewing! display.setcontrast(50); //set Contrast display.cleardisplay(); // 清除螢幕 display.display(); // show splashscreen // // draw a 多個矩形 for (int16_t i=0; i<display.height()/2; i+=4) { // display.drawtriangle(x0,y0,x1,y1,x2,y2, 顏色 ); display.drawtriangle(display.width()/2, i, 0+i*2, display.height()-2-i, display.width()-i*2, display.height()-2-i, BLACK); display.display(); // delay(2000) ; display.display(); 要的 delay(2000); // 顯示所有上面內容, 必要在所有秀字命令後, 一定 void loop() { // put your main code here, to run repeatedly: 程式下載網址 : https://github.com/brucetsao/makerdiwo/tree/master/201608 如下圖所示, 我們可以看到 Nokia 5110 LCD 模組畫出幾何圖形 : 三角形幾
何形狀 ( 曹永忠, 2016a, 2016b, 2016c, 2016d; 曹永忠, 許智誠, et al., 2015a, 2015b, 2015c, 2015d, 2015e, 2015f; 曹永忠, 許碩芳, et al., 2015a, 2015b) 圖 7 Nokia 5110 LCD 模組畫三角形幾何形狀測試程式一結果畫面 本文為 物聯網系列 系列第三篇 : 單色圖形顯示介紹 (NOKIA 5110 LCD 開發篇 ), 主要是介紹物聯網產品開發時, 常用的單色圖形微型 LCD 顯示介面, 如何顯示資料 文字 畫出幾何圖形等在顯示螢幕上 本篇是作者開啟的一個新專欄 : 物聯網系列, 主要是透過本專欄的介紹, 讓讀者可以了解物聯網 (Internet of Thing:IOT) 更多相關的使用 開發 設計等技術, 期望在往後專欄之中, 可以實作出更多物聯網的產品或實驗, 後續筆者還會繼續發表 物聯網系列 系列的文章, 在未來我們可以創造出更優質, 更具未來性的物聯網 (Internet of Thing:IOT) 產品開發相關技術 敬請期待更多的文章 筆者介紹曹永忠 (Yung-Chung Tsao): 目前為自由作家, 專注於軟體工程 軟體開發與
設計計 物件導向向程式設計計 物聯網系系統開發 Arduino 開發 嵌入式式系統開發, 商品品攝影及人人像攝影 長長期投入資資訊系統設計計與開發 企業應用系系統開發 軟體工工程 新產產品開發管理理 商品及及人像攝影等等領域, 並持續發表作作品及相關關專業著著作 Email:prgbruce@gmail. com,line ID:dr. brucetsaoo Arduino 部落格 :http://taiwanarduino.blogspot.tw// 臉書書社群 (Arduino.Taiwan):https://www.facebook.com/groups/Arduino.Taiwan/ 活動動官網 :http://arduino.kktix.cc/ Youtube:https://www. youtube.com/channel/uccyg2yy_u0m1aotca4hrrgq 程式式下載網址 :https://github.com/brucetsao/makerdiwo 參考考文獻 : 曹永永忠. (2016a). 物聯網系系列 : 彩色色顯示介紹 (2.4~3.2 TFT 基本篇篇 ) 智慧家庭. Retrieved from https://vmaker.tw/archives/10466 曹永永忠. (2016b). 物聯網系列 : 彩色色顯示介紹 (2.4~3.2 TFT 進階篇篇 ). 智慧家庭. Retrieved from https://vmaker.tw/archives/10466 曹永永忠. (2016c). 物聯網系系列 : 彩色色顯示介紹 (OLED LCD 篇 ). 智智慧家庭. Retrieved from http://vmaker. tw/project/view/1102 曹永永忠. (2016d). 物聯網系列 : 單色色圖形顯示介介紹 (NOKIA 5110 LCD 基本篇 ).) 智慧家庭. Retrieved from https://vmaker.tw/ 曹永永忠. (2016e). 智慧家庭 : 如何安安裝各類感測器的函式式庫. 智慧家家庭. Retrieved from http://vmaker. tw/project/view/651 曹永永忠, 許智誠, & 蔡英英德. (2015a). Arduino 程式教學 ( 入門篇 ):Arduino Programming (Basic Skills & Tricks) ( 初版 ed.). 台湾 彰化 : 渥玛数位有有限公司. 曹永永忠, 許智誠, & 蔡英英德. (2015b). Arduino 程式教學 ( 常用模組篇篇 ):Arduino Programming (37 Sensor Modules) ( 初版 ed.). 台湾湾 彰化 : 渥渥玛数位有有限公司. 曹永永忠, 許智誠, & 蔡英英德. (2015c). Arduino 程式教學 ( 無線通訊篇篇 ):Arduino Programming (Wireless Communication) ( 初版 ed.) ). 台湾 彰彰化 : 渥瑪數數位有限公公司. 曹永永忠, 許智誠, & 蔡英英德. (2015d). Arduino 编程教学 ( 无线通讯篇篇 ):Arduino
Programming (Wireless Communication) ( 初版 ed.). 台湾 彰化 : 渥瑪數位有限公司. 曹永忠, 許智誠, & 蔡英德. (2015e). Arduino 编程教学 ( 常用模块篇 ):Arduino Programming (37 Sensor Modules) ( 初版 ed.). 台湾 彰化 : 渥玛数位有限公司. 曹永忠, 許智誠, & 蔡英德. (2015f). Arduino 編程教学 ( 入门篇 ):Arduino Programming (Basic Skills & Tricks) ( 初版 ed.). 台湾 彰化 : 渥玛数位有限公司. 曹永忠, 許碩芳, 許智誠, & 蔡英德. (2015a). Arduino 程式教學 (RFID 模組篇 ):Arduino Programming (RFID Sensors Kit) ( 初版 ed.). 台湾 彰化 : 渥瑪數位有限公司. 曹永忠, 許碩芳, 許智誠, & 蔡英德. (2015b). Arduino 編程教学 (RFID 模块篇 ):Arduino Programming (RFID Sensors Kit) ( 初版 ed.). 台湾 彰化 : 渥瑪數位有限公司.