LCD1602 库函数

This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-basedLCDs. The library works with in either 4- or 8-bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines).

Function

LiquidCrystal()

begin()

clear()

home()

setCursor()

write()

print()

cursor()

noCursor()

blink()

noBlink()

display()

noDisplay()

scrollDisplayLeft()

scrollDisplayRight()

autoscroll()

noAutoscroll()

leftToRight()

rightToLeft()

createChar()

详细解释

LiquidCrystal()  LiquidCrystal类的构造函数,初始化LCD

Description描述

Creates a variable of type LiquidCrystal. The display can be controlled using 4 or 8 data lines. If the former, omit the pin numbers for d0 to d3 and leave those lines unconnected. The RW pin can be tied to ground instead of connected to a pin on the Arduino; if so, omit it from this function's parameters.

Syntax语法

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)

Parameters参数

rs: the number of the Arduino pin that is connected to the RS pin on the LCD 数据/命令选择引脚

rw: the number of the Arduino pin that is connected to the RW pin on the LCD (optional) 读写引脚

enable: the number of the Arduino pin that is connected to the enable pin on the LCD  使能引脚

d0, d1, d2, d3, d4, d5, d6, d7: the numbers of the Arduino pins that are connected to the corresponding data pins on the LCD. d0, d1, d2, and d3 are optional; if omitted, the LCD will be controlled using only the four data lines (d4, d5, d6, d7).  数据引脚,8个或4

 

Example示例

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
void setup()
{
  lcd.begin(16,1);
  lcd.print("hello, world!");
}

void loop() {}

 

begin() 初始化LCD的界面,设置LCD尺寸

Description

Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the display. begin()needs to be called before any other LCD library commands.

Syntax

lcd.begin(cols, rows)

Parameters

lcd: a variable of type LiquidCrystal

cols: the number of columns that the display has 列数

rows: the number of rows that the display has  行数

clear()  清屏,光标在左上角

Description

Clears the LCD screen and positions the cursor in the upper-left corner.

Syntax

lcd.clear()

Parameters

lcd: a variable of type LiquidCrystal

home() 光标复位,定位于左上角

Description

Positions the cursor in the upper-left of the LCD. That is, use that location in outputting subsequent text to the display. To also clear the display, use the clear() function instead.

Syntax

lcd.home()

Parameters

lcd: a variable of type LiquidCrystal

setCursor() 设置光标位置

Description

Position the LCD cursor; that is, set the location at which subsequent text written to the LCD will be displayed.

Syntax

lcd.setCursor(col, row)

Parameters

lcd: a variable of type LiquidCrystal

col: the column at which to position the cursor (with 0 being the first column)

row: the row at which to position the cursor (with 0 being the first row)

write() 写一个字符到LCD

Description

Write a character to the LCD.

Syntax

lcd.write(data)

Parameters

lcd: a variable of type LiquidCrystal

data: the character to write to the display

Returns

byte
write() will return the number of bytes written, though reading that number is optional

 

Example

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
void setup()
{
  Serial.begin(9600);
}
void loop()
{
   if (Serial.available())

{
     lcd.write(Serial.read());
  }
}

print()  文本输出到LCD

Description

Prints text to the LCD.

Syntax

lcd.print(data) 
lcd.print(data, BASE)  输出格式可以是二进制,十进制,八进制,十六进制

Parameters

lcd: a variable of type LiquidCrystal

data: the data to print (char, byte, int, long, or string)

BASE (optional): the base in which to print numbers: BIN for binary (base 2), DEC for decimal (base 10), OCT for octal (base 8), HEX for hexadecimal (base 16).

Returns

byte
print() will return the number of bytes written, though reading that number is optional

 

Example

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
void setup()
{
  lcd.print("hello, world!");
}
void loop() {}

cursor()   显示光标

Description

Display the LCD cursor: an underscore (line) at the position to which the next character will be written.

Syntax

lcd.cursor()

Parameters

lcd: a variable of type LiquidCrystal

noCursor()  隐藏光标

Description

Hides the LCD cursor.

Syntax

lcd.noCursor()

Parameters

lcd: a variable of type LiquidCrystal

blink()  光标闪烁

Description

Display the blinking LCD cursor. If used in combination with the cursor() function, the result will depend on the particular display.

Syntax

lcd.blink()

Parameters

lcd: a variable of type LiquidCrystal

noBlink()  光标不闪烁

Description

Turns off the blinking LCD cursor.

Syntax

lcd.noBlink()

Parameters

lcd: a variable of type LiquidCrystal

display()  开启LCD显示功能,

Description

Turns on the LCD display, after it's been turned off with noDisplay(). This will restore the text (and cursor) that was on the display.

Syntax

lcd.display()

Parameters

lcd: a variable of type LiquidCrystal

noDisplay()  关闭LCD显示功能,但之前的显示内容不丢失

Description

Turns off the LCD display, without losing the text currently shown on it.

Syntax

lcd.noDisplay()

Parameters

lcd: a variable of type LiquidCrystal

scrollDisplayLeft()  向左滚屏,LCD显示的内容往左移一格

Description

Scrolls the contents of the display (text and cursor) one space to the left.

Syntax

lcd.scrollDisplayLeft()

Parameters

lcd: a variable of type LiquidCrystal

scrollDisplayRight()  向右滚屏,显示的内容往右移一格

Description

Scrolls the contents of the display (text and cursor) one space to the right.

Syntax

lcd.scrollDisplayRight()

Parameters

lcd: a variable of type LiquidCrystal

autoscroll()  自动滚屏,输入时光标在一个固定位置,字符自动移动

Description

Turns on automatic scrolling of the LCD. This causes each character output to the display to push previous characters over by one space. If the current text direction is left-to-right (the default), the display scrolls to the left; if the current direction is right-to-left, the display scrolls to the right. This has the effect of outputting each new character to the same location on the LCD.

Syntax

lcd.autoscroll()

Parameters

lcd: a variable of type LiquidCrystal

 

noAutoscroll() 关闭自动滚屏

Description

Turns off automatic scrolling of the LCD.

Syntax

lcd.noAutoscroll()

Parameters

lcd: a variable of type LiquidCrystal

leftToRight() 文本显示时的移动方向是从左往右,默认方向

Description

Set the direction for text written to the LCD to left-to-right, the default. This means that subsequent characters written to the display will go from left to right, but does not affect previously-output text.

Syntax

lcd.leftToRight()

Parameters

lcd: a variable of type LiquidCrystal

rightToLeft() 文本显示时的移动方向是从右往左

Description

Set the direction for text written to the LCD to right-to-left (the default is left-to-right). This means that subsequent characters written to the display will go from right to left, but does not affect previously-output text.

Syntax

lcd.rightToLeft()

Parameters

lcd: a variable of type LiquidCrystal

createChar() 建立一个自定义的图形字符

Description

Create a custom character (glyph) for use on the LCD. Up to eight characters of 5x8 pixels are supported (numbered 0 to 7). The appearance of each custom character is specified by an array of eight bytes, one for each row. The five least significant bits of each byte determine the pixels in that row. To display a custom character on the screen, write() its number.

NB : When referencing custom character "0", if it is not in a variable, you need to cast it as a byte, otherwise the compiler throws an error. See the example below.

Syntax

lcd.createChar(num, data)

Parameters

lcd: a variable of type LiquidCrystal

num: which character to create (0 to 7)

data: the character's pixel data

Example

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

byte smiley[8] =   //微笑图案

{

B11011,

B00000,

B01010,

B00000,

B00000,

B10001,

B10001,

B01110,

};

void setup()

{

lcd.createChar(0, smiley);

lcd.begin(16, 2);

lcd.write(byte(0));

}

void loop() {}

LCD1602 库函数的更多相关文章

  1. ARDUINO驱动LCD1602 (利用库函数)

    LCD 1602简介 工业字符型液晶,能够同时显示16x02即32个字符.(16列2行) 1602液晶也叫1602字符型液晶,它是一种专门用来显示字母.数字.符号等的点阵型液晶模块.它由若干个5X7或 ...

  2. Arduino下LCD1602综合探究(上)——1602的两种驱动方式,如何使LCD的控制编程变得更简单

    一.前言: LCD ( Liquid Crystal Display 的简称)液晶显示器,已经逐渐替代CRT成为主流的显示设备之一,因此也成为了单片机发烧友绕不过的话题之一:而LCD1602更是很多单 ...

  3. Entity Framework 6 Recipes 2nd Edition(11-11)译 -> 在LINQ中调用数据库函数

    11-11. 在LINQ中调用数据库函数 问题 相要在一个LINQ 查询中调用数据库函数. 解决方案 假设有一个任命(Appointment )实体模型,如Figure 11-11.所示, 我们想要查 ...

  4. Linux系统调用和库函数调用的区别

    Linux下对文件操作有两种方式:系统调用(system call)和库函数调用(Library functions).系统调用实际上就是指最底层的一个调用,在linux程序设计里面就是底层调用的意思 ...

  5. Arduino下LCD1602综合探究(下)——如何减少1602的连线,LiquidCrystal库,LiquidCrystal库中bug的解决方法

    一.前言: 上文中,笔者系统的阐述了1602的两种驱动方式,并简单的提到了Arduino的LiquidCrystal库.本文紧接上文,对以下两个问题进行更加深入的探讨:如何能够使1602对Arduin ...

  6. C标准I/O库函数与Unbuffered I/O函数

    一.C标准I/O库函数.Unbuffered I/O函数 1. C标准I/O库函数是如何用系统调用的 fopen(3) 调用open(2)打开制定的文件,返回一个文件描述符(一个int类型的编号),分 ...

  7. [Django]模型提高部分--聚合(group by)和条件表达式+数据库函数

    前言:本文以学习记录的形式发表出来,前段时间苦于照模型聚合中group by 找了很久,官方文章中没有很明确的说出group by,但在文档中有提到!!! 正文(最后编辑于2016-11-12): 聚 ...

  8. STM32库函数编程、Keli/MDK、stm32f103zet6

    catalogue . Cortex-M3地址空间 . 基于标准外设库的软件开发 . 基于固件库实现串口输出(发送)程序 . 红外接收实验 . 深入分析流水灯例程 . GPIO再举例之按键实验 . 串 ...

  9. LPC1768/1769之CAN控制器概述(附库函数下载地址)

    一.背景: 使用LPC1769来做CAN的收发,在此对使用LPC1769的CAN控制器进行收发做个总结和记录,以备下 次开发快速上手使用. 附:LPC1768/1769除了支持最高频率不同以外,其它基 ...

随机推荐

  1. 如何用python制作贪吃蛇以及AI版贪吃蛇

    用python制作普通贪吃蛇 哈喽,大家不知道是上午好还是中午好还是下午好还是晚上好! 很多人学习python,不知道从何学起.很多人学习python,掌握了基本语法过后,不知道在哪里寻找案例上手.很 ...

  2. 不要再纠结css/js/html有没有必要放在WEB-INF下了

    原因 首先,css/js/html没有必要放在WEB-INF下. 最终这些会被原封不动的展现在客户端,所以访问安全根本就不会成为问题. jsp放在web-inf下,原因主要有两个 1. 远古时代的模式 ...

  3. 用Nginx将web请求引导到本机两个tomcat

    如何在本机启动两个tomcat请参考:https://www.cnblogs.com/xiandedanteng/p/12100461.html 而Nginx这边,将\conf\nginx.conf ...

  4. spring cloud 通过zuul网关去请求的时候报404的几个原因。

    spring cloud 中 zuul 网关的那些坑: 1.检查你的服务是否正常启动. 2.检查你的服务是否正常注册到注册中心. 3.zuul网关的路由规则是会把你注册在注册中心的serviceId ...

  5. 车联网容器应用探索:5G下边缘云计算的车路协同实践

    导语 | 5G网络下,多接入边缘计算(MEC)应运而生.结合TKEStack强大的集群管理能力和异构计算资源管理能力,腾讯打造了一个功能完备的边缘计算PaaS平台TMEC,提供了高精确度定位.视频处理 ...

  6. TP6.0多应用模式隐藏路由中的应用名

    本文默认采用的是多应用模式 PHP技术群: 159789818 ThinkPHP技术群: 828567087 1. 多应用模式中隐藏路由中的应用名的三种方式 域名绑定应用 增加应用入口 入口文件绑定应 ...

  7. 【高并发】Redis如何助力高并发秒杀系统,看完这篇我彻底懂了!!

    写在前面 之前,我们在<[高并发]高并发秒杀系统架构解密,不是所有的秒杀都是秒杀!>一文中,详细讲解了高并发秒杀系统的架构设计,其中,我们介绍了可以使用Redis存储秒杀商品的库存数量.很 ...

  8. canvas绘制图片drawImage学习

    不得不说,html5中的canvas真的非常强大,从图片处理,到视频处理,再到游戏开发,都能见到canvas的身影,然而,就这一个<canvas>标签,功能居然如此强大,这主要归功于can ...

  9. 猜数字 python 3

    随机选取一个1-100的整数 通过5次机会猜整数 会提醒猜大或者猜小 当猜对或者已经猜过5次后结束游戏

  10. swift基本数据类型使用-字典使用

    目录 1.定义的定义 2.对可变字典的基本操作 3.遍历字典 4.字典合并 5.示例 1.定义的定义 1> 不可变字典: let 2> 可变字典: var 2.对可变字典的基本操作 增删改 ...