หมวดวิศวกรรม/เทคโนโลยียานยนต์ => การทดสอบกล่อง => การซ่อมกล่อง ECU => กล่อง ECU => อิเล็กทรอนิกส์ยานยนต์ => Arduino for CAR => ข้อความที่เริ่มโดย: Auto Man ที่ 09 กรกฎาคม 2565, 10:29:51

หัวข้อ: มาทำความรู้จักกับ LCD Keypadshied 1602 LCD 16x2 Keypad Shield
เริ่มหัวข้อโดย: Auto Man ที่ 09 กรกฎาคม 2565, 10:29:51
   มาทำความรู้จักกับ LCD Keypadshied 1602 LCD 16x2 Keypad Shield   
   โมดูล LCD Keypadshied 1602 LCD 16x2 Keypad Shield for Arduino LCD 1602 Keypad Shield

ตรงนี้มีภาพ! แต่ท่านจะมองไม่เห็น , ท่านต้อง  สมัครสมาชิก หรือ ลงชื่อเข้าระบบ
 (http://upic.me/show/62801360)

   ในการใช้งาน Arduino หรือทำโปรเจกอิเล็กทรอนิกส์ ส่วนสำคัญที่ส่วนมากจะต้องมีก็คือหน้าจอแสดงผล
เราสามารถแสดงผลออกได้หลายแบบ เช่น 7 segment หรือ led หรือจะใช้จอ LCD ซึ่งเป็นตัวที่ใช้กัน
มากที่สุดตัวหนึ่งในการแสดงผล ทั้งแบบข้อความและแบบกราฟฟิก

     จอ LCD ทั่วไปที่มีราคาถูกและใช้งานง่ายคือจอ LCD ที่แสดงผลแบบตัวอักษร เช่น จอ LCD ขนาด 16 บรรทัด
2 แถว เรียกว่า LCD 1602 หรือ LCD 16x2 แสดงตัวอักษรได้ 32 ตัว การใช้งานจอ LCD แบบนี้ง่ายมาก
และสามารถใช้ได้กับ Arduino / ESP32 / ESP8266 และบอร์ดไมโครคอนโทรลเลอร์อื่น ๆ ได้เกือบทุกบอร์ด

     จอ LCD อาจมีขาจำนวนมากในการต่อเพื่อควบคุม เพื่อให้การใช้งานง่ายที่สุด จึงมีการผลิตจอ LCD
ที่แบบ Shield พร้อมปุ่มกดในการรับค่าเพื่อเป็น INPUT ให้กับ Arduino เช่น ใช้ทำปุ่มเลือกเมนู เรียวกว่า
บอร์ด LCD Keypad Shield ออกแบบมาสำหรับ Arduino โดยเฉพาะ แค่เสียบก็พร้อมใช้งาน

LCD Keypad Shield คือบอร์ดจอแสดงผล + ปุ่มกด 5 ปุ่ม ที่ออกแบบมาสำหรับ Arduino โดยเฉพาะ
จึงใช้งานง่าย ปุ่มกดที่มาพร้อมกับจอทำให้เราสามารถเป็นเมนูที่หน้าจอ ใช้ปุ่มกดเลื่อนเมนู ขึ้น ลง ซ้าย ขวา
เลือกเมนู ได้ง่ายไม่ต้องต่ออะไรเพิ่ม ปุ่มกด 5 ปุ่มเป็นการสื่อสารแบบ Analog จากการต่อสวิตช์ปกติต้องใช้
GPIO 5 ขา ก็เหลือเพียงแค่ 1 ขา ประหยัดไปได้ 4 ขาเหลือสำหรับต่อกับเซนเซอร์และอุปกรณ์ตัวอื่น ๆ
หัวข้อ: มาทำความรู้จักกับ LCD Keypadshied 1602 LCD 16x2 Keypad Shield
เริ่มหัวข้อโดย: Auto Man ที่ 09 กรกฎาคม 2565, 10:34:49
   ตำแหน่งขาของบอร์ด LCD Keypad Shield   

ตรงนี้มีภาพ! แต่ท่านจะมองไม่เห็น , ท่านต้อง  สมัครสมาชิก หรือ ลงชื่อเข้าระบบ
 (http://upic.me/show/62801361)
ตรงนี้มีภาพ! แต่ท่านจะมองไม่เห็น , ท่านต้อง  สมัครสมาชิก หรือ ลงชื่อเข้าระบบ
 (http://upic.me/show/62801362)
ตรงนี้มีภาพ! แต่ท่านจะมองไม่เห็น , ท่านต้อง  สมัครสมาชิก หรือ ลงชื่อเข้าระบบ
 (http://upic.me/show/62801363)
หัวข้อ: มาทำความรู้จักกับ LCD Keypadshied 1602 LCD 16x2 Keypad Shield
เริ่มหัวข้อโดย: Auto Man ที่ 09 กรกฎาคม 2565, 10:39:09
วิธีใช้งาน LCD Keypad Shield

อุปกรณ์ทดลอง LCD Keypad Shield
 - arduino
 - shield lcd

การต่อวงจร LCD Keypad Shield

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

โค๊ด: [Select]
#include <LiquidCrystal.h>
//LCD pin to Arduino Example By ArduinoAll
const int pin_RS = 8;
const int pin_EN = 9;
const int pin_d4 = 4;
const int pin_d5 = 5;
const int pin_d6 = 6;
const int pin_d7 = 7;
const int pin_BL = 10;
LiquidCrystal lcd( pin_RS,  pin_EN,  pin_d4,  pin_d5,  pin_d6,  pin_d7);
void setup() {
  lcd.begin(16, 2);
  lcd.setCursor(0, 0); // กำหนดตำแหน่ง Cursor
  lcd.print("www.auto-nkp.com");// แสดงข้อความออกจอ LCD
  lcd.setCursor(0, 1);
  lcd.print("Press Key:");
}
void loop() {
  int x;
  x = analogRead (0); // อ่านค่า ที่ผู้ใช้กดปุ่มเข้ามา
  lcd.setCursor(10, 1);
 
  if (x < 60) {
    lcd.print ("Right ");
  }
  else if (x < 200) {
    lcd.print ("Up    ");
  }
  else if (x < 400) {
    lcd.print ("Down  ");
  }
  else if (x < 600) {
    lcd.print ("Left  ");
  }
  else if (x < 800) {
    lcd.print ("Select");
  }
}
หัวข้อ: มาทำความรู้จักกับ LCD Keypadshied 1602 LCD 16x2 Keypad Shield
เริ่มหัวข้อโดย: Auto Man ที่ 09 กรกฎาคม 2565, 10:46:59
   ข้อมูลเพิ่มเติม LCD Keypad Shield   

 - วงจร    Schematic Arduino LCD Keypad Shield   

ตรงนี้มีภาพ! แต่ท่านจะมองไม่เห็น , ท่านต้อง  สมัครสมาชิก หรือ ลงชื่อเข้าระบบ
 (https://drive.google.com/file/d/14-DymouljtEA5bGZi1MeEO9wdI7XvxpX/view?usp=sharing)
หัวข้อ: มาทำความรู้จักกับ LCD Keypadshied 1602 LCD 16x2 Keypad Shield
เริ่มหัวข้อโดย: Auto Man ที่ 09 กรกฎาคม 2565, 10:53:48
จอแสดงผล LCD ขนาด 16 ตัวอักษร 2 บรรทัด พร้อมปุ่มกด สามารถใช้ป้อนค่าปุ่มที่กดให้กับ Arduino เอาไปควบคุมข้อมูลต่าง ๆ ที่ต้องการได้อย่างสะดวก ไม่ต้องต่อสายเพิ่ม แค่เสียบก็พร้อมใช้งาน เหมาะสำหรับงานแสดงผลข้อมูลออกจอ LCD ที่ต้องการรับค่าปุ่มจากผู้ใช้ไปประมวลผล

ตัวอย่างโค๊ด Arduino LCD Keypad

โค๊ด: [Select]
// อัพโหลดเสร็จ ปรับความสว่างของจอ LCD โดยหมุนตามเข็มนาฬิกาเพื่อให้ตัวอักษรเข้มขึ้น

//Sample using LiquidCrystal library

#include

 

/*******************************************************

 

This program will test the LCD panel and the buttons

Mark Bramwell, July 2010

 

********************************************************/

 

// select the pins used on the LCD panel

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

 

// define some values used by the panel and buttons

int lcd_key     = 0;

int adc_key_in  = 0;

#define btnRIGHT  0

#define btnUP     1

#define btnDOWN   2

#define btnLEFT   3

#define btnSELECT 4

#define btnNONE   5

 

// read the buttons

int read_LCD_buttons()

{

 adc_key_in = analogRead(0);      // read the value from the sensor

 // my buttons when read are centered at these valies: 0, 144, 329, 504, 741

 // we add approx 50 to those values and check to see if we are close

 if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result

 // For V1.1 us this threshold

 if (adc_key_in < 50)   return btnRIGHT; 

 if (adc_key_in < 250)  return btnUP;

 if (adc_key_in < 450)  return btnDOWN;

 if (adc_key_in < 650)  return btnLEFT;

 if (adc_key_in < 850)  return btnSELECT; 

 

 // For V1.0 comment the other threshold and use the one below:

/*

 if (adc_key_in < 50)   return btnRIGHT; 

 if (adc_key_in < 195)  return btnUP;

 if (adc_key_in < 380)  return btnDOWN;

 if (adc_key_in < 555)  return btnLEFT;

 if (adc_key_in < 790)  return btnSELECT;   

*/

 

 

 return btnNONE;  // when all others fail, return this...

}

 

void setup()

{

 lcd.begin(16, 2);              // start the library

 lcd.setCursor(0,0);

 lcd.print("Push the buttons"); // print a simple message

 Serial.begin(9600);

}

 

void loop()

{

 lcd.setCursor(9,1);            // move cursor to second line "1" and 9 spaces over

 lcd.print(millis()/1000);      // display seconds elapsed since power-up

 

 

 lcd.setCursor(0,1);            // move to the begining of the second line

 lcd_key = read_LCD_buttons();  // read the buttons

 

 switch (lcd_key)               // depending on which button was pushed, we perform an action

 {

   case btnRIGHT:

     {

     lcd.print("RIGHT ");

     break;

     }

   case btnLEFT:

     {

     lcd.print("LEFT   ");

     break;

     }

   case btnUP:

     {

     lcd.print("UP    ");

     break;

     }

   case btnDOWN:

     {

     lcd.print("DOWN  ");

     break;

     }

   case btnSELECT:

     {

     lcd.print("SELECT");

     break;

     }

     case btnNONE:

     {

     lcd.print("NONE  ");

     break;

     }

 }

 

 

}
หัวข้อ: มาทำความรู้จักกับ LCD Keypadshied 1602 LCD 16x2 Keypad Shield
เริ่มหัวข้อโดย: Auto Man ที่ 09 กรกฎาคม 2565, 10:54:29
หัวข้อ: มาทำความรู้จักกับ LCD Keypadshied 1602 LCD 16x2 Keypad Shield
เริ่มหัวข้อโดย: Auto Man ที่ 09 กรกฎาคม 2565, 11:52:37
   กระทู้นำข้อมูลมาจากที่นี่ allnewstep.com (https://www.allnewstep.com/product/49/%E0%B9%82%E0%B8%A1%E0%B8%94%E0%B8%B9%E0%B8%A5-lcd-keypadshied-1602-lcd-16x2-keypad-shield-for-arduino-lcd-1602-keypad-shield)

   
 

allnewstep.com