Difference between revisions of "Matrix - I2C LCD1602"

From FriendlyELEC WiKi
Jump to: navigation, search
Line 1: Line 1:
 
[[Matrix - I2C LCD1602/zh|查看中文]]
 
[[Matrix - I2C LCD1602/zh|查看中文]]
  
==介绍==
+
==Introduction==
 
[[File:LCD160201.png|thumb|I2C LCD1602]]
 
[[File:LCD160201.png|thumb|I2C LCD1602]]
 
[[File:LCD160202.png|thumb|I2C LCD1602]]
 
[[File:LCD160202.png|thumb|I2C LCD1602]]
带有I2C控制器的LCD1602液晶显示屏。LCD1602是可以显示16x2个字符的液晶显示屏,本身是并行接口,主控需要较多的IO资源才可以与之通讯。为了节约IO资源和控制简单,我们专门设计了一个控制器,主控通过I2C总线跟控制器通讯,控制器再把主控发来信息转换成并行信号发送给LCD1602。搭配控制器,主控可以通过I2C总线发送显示信号,关闭或打开背光。
+
This is an LCD module which has an I2C controller. It can display 16 x 2 characters. Its interface is parallel. To simplify its application we designed a controller which interfaces with other modules through I2C and transfers received signals to parallel signals to LCD1602. It can display,  turn on and off back light.
  
 
==特性==
 
==特性==

Revision as of 07:59, 5 August 2015

查看中文

1 Introduction

I2C LCD1602
I2C LCD1602

This is an LCD module which has an I2C controller. It can display 16 x 2 characters. Its interface is parallel. To simplify its application we designed a controller which interfaces with other modules through I2C and transfers received signals to parallel signals to LCD1602. It can display, turn on and off back light.

2 特性

  • I2C通讯,显示和背光可控
  • 2.54mm排针接口,接线方便,通用性强

3 使用方法

3.1 连接

  • 连接到Tiny4412 SDK (1506)
GND: 接地
VCC: 接5V
SDA: I2C SDA
SCL: I2C SCL

3.2 Linux下的C示例

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include "libfahw.h"
 
void test(char* line1, char* line2)
{
    int devFD;
    if ((devFD = LCD1602Init()) == -1) {
        printf("Fail to init LCD1602\n");
        return;
    }
 
            if (LCD1602Clear(devFD) == -1) {
                    printf("Fail to Clear\n");
                    return;
            }
 
    if (LCD1602DispLines(devFD, line1, line2) == -1) {
        printf("Fail to Display String\n");
        return ;
    }
 
    LCD1602DeInit(devFD);
}
 
int main(int argc, char ** argv) {
    int i;
    for (i=0; i<10; i++) {
         test("FriendlyARM", "From 2003");
         sleep(3);
    }
    return 0;
}

3.3 编译并运行示例

git clone http://github.com/friendlyarm/fa-hardware.git
cd fa-hardware
cd demo
cd matrix-i2c_lcd1602
make

将编译生成的LCD1602通过ftp上传到开发板上运行即可测试。

4 相关资料