“1602 LCD”的版本间的差异

来自Labplus盛思维基百科
跳转至: 导航搜索
技术参数
使用教程
第24行: 第24行:
 
=== 连接示意图 ===
 
=== 连接示意图 ===
 
=== Arduino示例 ===
 
=== Arduino示例 ===
=== MicroPython示例 ===
+
Arduino库文件
 
<pre style="color:blue">
 
<pre style="color:blue">
from microbit import *
+
/*
 +
  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
 +
* LCD R/W pin to ground
 +
* LCD VSS pin to ground
 +
* LCD VCC pin to 5V
 +
* 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 22 Nov 2010
 +
by Tom Igoe
 +
 
 +
This example code is in the public domain.
 +
 
 +
http://www.arduino.cc/en/Tutorial/LiquidCrystal
 +
*/
 +
 
 +
// include the library code:
 +
#include <LCD1602.h>
 +
#include <Wire.h>
 +
 
 +
// initialize the library with the numbers of the interface pins
 +
LiquidCrystal lcd;
 +
 
 +
void setup() {
 +
  // set up the LCD's number of columns and rows:
 +
  Wire.begin();
 +
  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);
 +
}
 +
 
  
def getTemp():
 
  i2c.write(0x40,bytearray([0xE3]))
 
  sleep(85)
 
  t=i2c.read(0x40,2)
 
  return -46.86+175.72*(t[0]*256+t[1])/65535
 
 
 
 
 
def getHumi():
 
  i2c.write(0x40,bytearray([0xE5]))
 
  sleep(40)
 
  t=i2c.read(0x40,2)
 
  return -6+125*(t[0]*256+t[1])/65536
 
 
 
while True:
 
    print('TEMP:',getTemp())  #获取温度并打印出来
 
    print('HUMi:',getHumi())  #获取湿度并打印出来
 
    sleep(500)
 
 
</pre>
 
</pre>
 
+
=== MicroPython示例 ===
 
=== 图形化示例 ===
 
=== 图形化示例 ===

2017年12月19日 (二) 16:52的版本

概述

16x2液晶显示字符模块,可用于显示字母、数字、字符等。I2C LCD1602液晶模块可以显示2行,每行16个字符。对于A初学者来说,不必为繁琐复杂液晶驱动电路连线而头疼了,这款LCD扩展板将电路简化,使用相关文档中的库文件,您只需使用几行简单控制代码便能完成LCD控制显示的功能。背面的电位器还能提供你调节液晶显示器对比度的功能。

技术参数

  • 工作电压:3.3V~5V
  • I2C数字信号输出
  • 背光:蓝色,白色字符
  • 可调节对比度
  • 模块尺寸:80x36x18.6mm

引脚定义

VCC 电源
SDA I2C数据
SCL I2C时钟
GND

使用教程

连接示意图

Arduino示例

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
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 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 22 Nov 2010
 by Tom Igoe

 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

// include the library code:
#include <LCD1602.h>
#include <Wire.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd;

void setup() {
  // set up the LCD's number of columns and rows:
  Wire.begin();
  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);
}


MicroPython示例

图形化示例