วันอังคารที่ 2 ธันวาคม พ.ศ. 2557

Arduino Uno and LCD TC1602A


พอดีวันนี้เกิดอารมณ์ว่างๆก็เลยเห็นจอ LCD   TC1602A  16*2 วางอยู่ไม่ได้ใช้งานเลยนึกสนุกจับใส่ กันลองดูให้มันเกิดไปวิ่งเป็นตัวอักษรขึ้นนั่นเองนะครับ  สำหรับใครว่างๆก็ลองทำดูนะครับ
..ลองมาดูขั้นตอนการทำเลยนะครับ ...

อุปกรณ์ที่ต้องเตรียม

1.เเน่นอนครับ บอร์ด Arduino Uno 1 บอรด
2. หน้าจอ LCD TC1602A
3. สายไฟต่อวงจร
4. ตัวต้านทานประมาณ 20-100 โอห์ม


การต่อวงจร ต่อตามนี้เลยนะครับ





















ซึ่งฝั่งซ้ายคือ ขา LCD ฝั่งขวา คือ arduino  pin นั่นเอง
โดยถ้าเราสังเกตที่ตารางนะครับ  ที่ขา 3 และ ขา 15 ของ LCD จะต้องมี ตัวต้านทานลิมิตเเรงดันไว้นะครับ   คือเอาไว้ปรับความสว่างหน้าจอนั่นเอง โดยใช้ตัวต้านทานประมาณ 40 โอหมก็ ได้นะโดยต่อ   แบบ อนุกรมนะครับ















เมื่อต่อวงจรเสร็จเเล้วนะครับ ก็อัปโหลดโค๊ตลงบอร์ด arduino ได้เลย นะครับ ตัวหนังสือก็จะวิ่ง ตามที่เราเขียนโปรเเกรมไว้นั่นเอง อันนี้ง่ายๆๆนะครับ เพื่อนๆลองทำดู
สำหรับโค๊ตโปรเเกรม ก๊อปด้านล่างเลยครับ
/////
#include <LiquidCrystal.h>

// Connections:
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

int backLight = 13;    // pin 13 will control the backlight

void setup()
{
  pinMode(backLight, OUTPUT);
  digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
  lcd.begin(16,2);              // columns, rows.  use 16,2 for a 16x2 LCD, etc.
  lcd.clear();                  // start with a blank screen
  lcd.setCursor(0,0);           // set cursor to column 0, row 0 (the first row)
  lcd.print("Hello, World");    // change this text to whatever you like. keep it clean.
  lcd.setCursor(0,1);           // set cursor to column 0, row 1
  lcd.print("kkclap & srv lap");

  // if you have a 4 row LCD, uncomment these lines to write to the bottom rows
  // and change the lcd.begin() statement above.
  //lcd.setCursor(0,2);         // set cursor to column 0, row 2
  //lcd.print("Row 3");
  //lcd.setCursor(0,3);         // set cursor to column 0, row 3
  //lcd.print("Row 4");
  delay(15000);
}

void loop()
{

 
  lcd.clear();
  lcd.begin(16,2);              // columns, rows.  use 16,2 for a 16x2 LCD, etc.                 // start with a blank screen
  lcd.setCursor(0,0);           // set cursor to column 0, row 0 (the first row)
  lcd.print("Hi My name");    // change this text to whatever you like. keep it clean.
  lcd.setCursor(0,1);           // set cursor to column 0, row 1
  lcd.print("keattisak kkm");
  delay(10000);
  lcd.setCursor(0,0);           // set cursor to column 0, row 0 (the first row)
  lcd.print("Study at kkc ");    // change this text to whatever you like. keep it clean.
  lcd.setCursor(0,1);           // set cursor to column 0, row 1
  lcd.print("RMUTI khonkean");
  delay(10000);
  lcd.clear();
  lcd.setCursor(0,0);           // set cursor to column 0, row 0 (the first row)
  lcd.print("keattisak80@gmail.com  ");    // change this text to whatever you like. keep it clean.
  lcd.setCursor(0,1);           // set cursor to column 0, row 1
  lcd.print("www.rfthailand.com");
  delay(10000);

}
///////

vdo ตัวอย่างที่เสร็จเเล้วนะครับ 



อ้างอิงจาก 
http://www.hacktronics.com/Tutorials/arduino-character-lcd-tutorial.html

ไม่มีความคิดเห็น:

แสดงความคิดเห็น