顯示具有 LCD 標籤的文章。 顯示所有文章
顯示具有 LCD 標籤的文章。 顯示所有文章

2014年12月29日 星期一

Lab09-ARDUINO LCD 游標閃動-第9個實驗練習

材料:
1•ARDUINO UNO R3 version with USB line
2•LCD1602a compatible with IC Hitachi 44780-相容前者IC的液晶螢幕顯示屏。
3•一堆線十幾條。
4•麵包板
5•可變電阻10K 或一般電阻9k-10k
#其實關於目前LCD 的操作,硬體接線基本上一致
官方提供的範例,沒有太難的難度
所以要找尋應用的範例,必須進入 Reference 與Blog 找找(右上角有搜尋文字框)
或者去網路上搜尋一下

ARDUINO IDE 開發環境官方程式碼載入位置


游標閃動的作用
應該是告訴我們目前正要寫入的位置,

那這有甚麼用呢? 我認為
1.就像Windows ,你知道它還活著
2.接下來的數入會不會超過顯示的可見區
3.移動由標記住選擇 設定選項 或者想要修改 顯示字元裡的字,然後用插入的動作來填入在適當的位置

官方程式碼 EXAMPLE 如下=======================

/*
  LiquidCrystal Library - Cursor
 液晶函式庫-游標
 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 展示 使用 一個 16x2 型號的 LCD 顯示屏. 這液晶
 library works with all LCD displays that are compatible with the
 函式庫 可操作 所有使用相容Hitachi HD44780 驅動器的 LCD.
 Hitachi HD44780 driver. There are many of them out there, and you
                         市面上有多種,
 can usually tell them by the 16-pin interface.
  你通常可從具16pin 接腳的介面來辨識出
 This sketch prints "Hello World!" to the LCD and
 這個腳本 輸出  " Hellow World! "到LCD 上,
 uses the cursor()  and noCursor() methods to turn
 並且使用 游標 cursor() 和 無游標 noCursor() 方法 來 
 on and off the cursor.
  開啓跟關閉 游標 (顯示或隱藏)

 The circuit: 電路
 * LCD RS pin to digital pin 12     -- LCD 上 RS腳位 接 ARDUINO 數位D12腳
 * LCD Enable pin to digital pin 11 --LCD 上致能腳位 接 ARDUINO 數位D11腳
 * LCD D4 pin to digital pin 5      ---LCD 上 D4 接 ARDUINO 數位D5
 * LCD D5 pin to digital pin 4         LCD 上 D5 接 ARDUINO 數位D4
 * LCD D6 pin to digital pin 3         LCD 上 D6 接 ARDUINO 數位D3
 * LCD D7 pin to digital pin 2         LCD 上 D7 接 ARDUINO 數位D2
 * LCD R/W pin to ground               LCD 上 R/W 接 ARDUINO GND 接地腳位
 * 10K resistor:                       10K 電阻(我的9.5K 對比較佳)
 * ends to +5V and ground              ㄧ端 接 正+5V, 一端接GND 負極  
 * wiper to LCD VO pin (pin 3)         從電阻後端 接分壓 線 接到LCD V0 腳位

 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe

 This example code is in the public domain.

 http://arduino.cc/en/Tutorial/LiquidCrystalCursor

 */

// include the library code: 加入 函式庫檔案
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins 初始化腳位定義
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows: 初始化 設定LCD 欄數與列數
  lcd.begin(16, 2);
  // Print a message to the LCD.  輸出 訊息 到LCD上
  lcd.print("hello, world!");
}

void loop() {
  // Turn off the cursor: 打開游標
  lcd.noCursor();
  delay(500);
  // Turn on the cursor: 關閉游標 
  lcd.cursor();
  delay(500);
}

硬體接線:

如一般的LCD範例
http://arduino.cc/en/Tutorial/LiquidCrystal





結果圖片:






結果影片:





可能遇到問題:

1.USB線沒接好
2.通訊PORT沒選對




應用思考題:

1.閃動快速 跟慢速 可否依據 傳輸速率或者電壓大小來動態改變 
2.偵測心跳速率 是否用 閃爍顯示心跳狀況? 
3.移動的位置 來反應使用這輸入的字元?

2014年12月28日 星期日

ARDUINO-LCD 函式庫

來源
http://blog.sina.com.cn/s/blog_5d940a1b0101344q.html



  1. LiquidCrystal()——定义你的LCD的接口:各个引脚连接的I/O口编号,格式为LiquidCrystal(rs,+enable,+d4,+d5,+d6,+d7)
    LiquidCrystal(rs,+rw,+enable,+d4,+d5,+d6,+d7)
    LiquidCrystal(rs,+enable,+d0,+d1,+d2,+d3,+d4,+d5,+d6,+d7)
    LiquidCrystal(rs,+rw,+enable,+d0,+d1,+d2,+d3,+d4,+d5,+d6,+d7)

  2. begin()——定义LCD的长宽(n列×n行),格式lcd.begin(cols,+rows)

  3. clear()——清空LCD,格式lcd.clear()

  4. home()——把光标移回左上角,即从头开始输出,格式lcd.home()

  5. setCursor()——移动光标到特定位置,格式lcd.setCursor(col,+row)

  6. write()——在屏幕上显示内容(必须是一个变量,如”Serial.read()”),格式lcd.write(data)

  7. print()——在屏幕上显示内容(字母、字符串,等等),格式lcd.print(data)
    lcd.print(data,+BASE)

  8. cursor()——显示光标(一条下划线),格式lcd.cursor()

  9. noCursor()——隐藏光标,格式lcd.noCursor()

  10. blink()——闪烁光标,格式lcd.blink()

  11. noBlink()——光标停止闪烁,格式lcd.noBlink()

  12. display()——(在使用noDisplay()函数关闭显示后)打开显示(并恢复原来内容),格式lcd.display()

  13. noDisplay()——关闭显示,但不会丢失原来显示的内容,格式为lcd.noDisplay()

  14. scrollDisplayLeft()——把显示的内容向左滚动一格,格式lcd.scrollDisplayLeft()

  15. scrollDisplayRight()——把显示的内容向右滚动一格,格式为lcd.scrollDisplayRight()

  16. autoscroll()——打开自动滚动,这使每个新的字符出现后,原有的字符都移动一格:如果字符一开始从左到右(默认),那么就往左移动一格,否则就向右移动,格式lcd.autoscroll()

  17. noAutoscroll()——关闭自动滚动,格式lcd.noAutoscroll()

  18. leftToRight()——从左往右显示,也就是说显示的字符会从左往右排列(默认),但屏幕上已经有的字符不受影响,格式lcd.leftToRight()

  19. rightToLeft()——从右往左显示,格式lcd.rightToLeft()

  20. createChar()——自造字符,最多5×8像素,编号0-7,字符的每个像素显示与否由数组里的数(0-不显示,1-显示)决定,格式lcd.createChar(num,+data),有点难理解,可以看一个例子

2014年12月15日 星期一

Lab06-ARDUINO:LCD"Hello world"液晶顯示屏-第6個實驗練習-1602A

ARDUINO UNO R3
LCD 顯示 "hello world"

引言;
1.已經做了幾個實驗後,終於開始想起要來寫實驗紀錄跟學習到的技巧與解決問題的技巧.
2.網路上很多高手,所以除了別人的案例,想做Arduino.cc的官網翻譯與官網案例翻譯並實驗.
3.寫些鏈結不同領域的東西進來發表,例如:LAbView + Arduino.或者 Arduino + PLC 等等.

先寫這篇主要因為想用ARDUINO 控制PLC 並在LCD 上顯示狀態.或者以燈號顯示狀態.

專案構思選擇:
(1)Arduino 與PLC RS232 通=> 要能傳出字串 ENQ+01+FF+BR+B+X0000+08+檢查碼
(2)Arduino 能夠獨立解析收到PCL傳出的字元STX+01+FF+BR+B+0+1+0+1+1+1..ETX,然後解析
(3)ARDUINO 解析後依據內容顯示 LCD 或 輸出燈號.或顯示在七段顯示器.

先查詢網上案例資源:
http://www.geek-workshop.com/thread-78-1-1.html
http://www.geek-workshop.com/forum.php?mod=viewthread&tid=955&highlight=lcd
http://blog.sina.com.cn/s/blog_6243051e01014ly8.html

---------------
待續再寫