วันเสาร์ที่ 8 สิงหาคม พ.ศ. 2558

เล่นกับ LCD LiquidCrystal, 1602 LCD (Blue Screen) 16x2 LCD with backlight of the LCD screen

มาดูอุปกรณ์ที่ต้องใช้กันเลยดีกว่า

1. Arduino UNO R3 Board
2. LCD Screen (compatible with Hitachi HD44780 driver)
3. pin headers to solder to the LCD display pins
4. 10k Potentiometer
5. 10K Resister
6. breadboard
7. hook-up wire

ที่นี้เรามาดูวิธีการต่อวงจรกัน ตามภาพนี้เลยครับ


LCD
Arduino
LCD
Arduino
1 GND
GND
9 DB2
Not connected
2 VDD
5V
10 DB3
Not connected
3 V0 (Contrast)
VR 10K
11 DB4
PIN 2
4 RS
PIN 0
12 DB5
PIN 5
5 RW
GND
13 DB6
PIN 6
6 E (Enable)
PIN 1
14 DB7
PIN 7
7 DB0
Not connected
15 A (Back LED+)
Resister 10K to 5V
8 DB1
Not connected
16 K (Back LED-)
GND

ต่อวงจรเสร็จขั้นตอนต่อไปก็เป็นการเขียนโปรแกรม ให้ท่านเขียนโปรแกรมตามนี้ เสร็จแล้วให้ทำการอัพโหลดโปรแกรมไปที่ Arduino ครับ

/*
  LiquidCrystal Library - Hello World
 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the 
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.
 This sketch prints "Hello World!" to the LCD
 and shows the time.
  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 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 25 July 2009
 by David A. Mellis
 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

// include the library code:
#include "Wire.h"
#include "LiquidCrystal.h"

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(0, 1, 2, 5, 6, 7);

void setup() {
  // set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}

โปรแกรมนี้เป็นตัวอย่างจากเว็ป http://www.arduino.cc/en/Tutorial/LiquidCrystal
ท่านสามารถเข้าไปดูรายละเอียดอื่นเพิ่มเติมได้จากเว็ปนี้
ถ้าหากมีข้อสงสัยเกี่ยวกับการใช้ VR ให้ท่านอ่านทำความเข้าใจได้จากบทความนี้ครับ http://berryduino.blogspot.com/2015/07/analog-arduino.html

1 ความคิดเห็น:

  1. Wynn casino to close from Monday to all-you-can-eat buffet
    It was announced 당진 출장샵 on Monday that Wynn Las Vegas will close the casino's 용인 출장샵 all-you-can-eat dining and lounge 경상북도 출장샵 area, and 통영 출장안마 all-you-can-eat dining 태백 출장샵

    ตอบลบ