当前位置:首页 > 科学研究 > 电子编程 > 正文内容

Arduino Project 023 - Liquid Crystal Displays - Hello World

RonWang2个月前 (10-23)电子编程69

Before wiring the LCD screen to your Arduino board we suggest to solder a pin header strip to the 14 (or 16) pin count connector of the LCD screen, as you can see in the image further up.

To start with, you will create a demonstration project that will show off most of the functions available in the LiquidCrystal.h library. To do so, you’ll use a backlit 16x2 LCD Display. 

Project 23 Liquid Crystal Displays -Hello World!

LCD_16x2 pin

To wire your LCD screen to your board, connect the following pins:

  • LCD RS pin to digital pin 9

  • LCD Enable pin to digital pin 8

  • 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

  • LCD R/W pin to GND

  • LCD VSS pin to GND

  • LCD VCC pin to 5V

  • LCD LED+ to 5V through a 220 ohm resistor

  • LCD LED- to GND

Arduino LCD Diagram 16X2

Additionally, wire a 10k potentiometer to +5V and GND, with it's wiper (output) to LCD screens VO pin (pin3).

Arduino LCD Schematic

/* Coding Ron Wang
   Oct.22nd 2024
   Autaba support for coding hardware
   Project 23  Basic LCD Control - Hello World !
 */
#include <LiquidCrystal.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 9, en = 8, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
  // set up the LCD's number of columns and rows:
  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);
}

Project 23-1 Liquid Crystal Displays - Text Direction Example

/* Coding Ron Wang
   Oct.23th 2024
   Autaba support for coding hardware
   Project 23-1 Basic LCD Control- Text Direction Example
 */
 
#include <LiquidCrystal.h>
// Initialize the library with the numbers of the interface pins
const int rs = 9, en = 8, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int thisChar = 'a';
void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // turn on the cursor:
  lcd.cursor();
}
void loop() {
  // reverse directions at 'm':
  if (thisChar == 'm') {
    // go right for the next letter
    lcd.rightToLeft();
  }
  // reverse again at 's':
  if (thisChar == 's') {
    // go left for the next letter
    lcd.leftToRight();
  }
  // reset at 'z':
  if (thisChar > 'z') {
    // go to (0,0):
    lcd.home();
    // start again at 0
    thisChar = 'a';
  }
  // print the character
  lcd.write(thisChar);
  // wait a second:
  delay(1000);
  // increment the letter:
  thisChar++;
}

版权声明:本文为原创文章,版权归donstudio所有,欢迎分享本文,转载请保留出处!

本文链接:http://parentscn.com/?id=273

标签: Arduino

相关文章

Arduino Project 034 - TM1637 4Digital 7Segment Display Module

Arduino Project 034 - TM1637 4Digital 7Segment Display Module

A standard 4-digit 7-segment display is needed for clock, timer and counter projects, but it usually...

Arduino Project 024 -  LCD Temperature Display

Arduino Project 024 - LCD Temperature Display

This project is a simple demonstration of using an LCD to present useful information to the user—in...

C语言调试运行环境TurboC的安装

C语言调试运行环境TurboC的安装

上大学时学习《C语言程序设计》(第二版)作者谭浩强,大部分编程时间是在学校机房度过,每次点开桌面的TurboC图标,就开始在里面敲代码,然后保存程序Abc.C,下一步进行编译,如果编译成功的话,就可以...

Arduino Project 045 - RFID Servo and LED Control System

Arduino Project 045 - RFID Servo and LED Control System

Arduino Programming Basic -- RFID Servo and LED Control System Project 45 RFID Servo...

 Arduino Project 033 - 4 Digital 7 Segment Display

Arduino Project 033 - 4 Digital 7 Segment Display

Showing Heep and number 0-9 on a Common Anode 7-segment LED display. Displays the numbers 0-9 on the...

Arduino Programming Basic - Bollean

Arduino Programming Basic - Bollean

Arduino 程序基础,介绍Arduino程序的基本组成,第一部分编写了10个例子,关于变量及变量名称,串口监视器,if循环,for循环,while循环等。第二部分介绍了函数,全局变量,局部变量和静...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。