Difference between revisions of "Matrix - I2C LCD1602"

From FriendlyELEC WiKi
Jump to: navigation, search
(特性)
(使用方法)
Line 10: Line 10:
 
* 2.54 mm spacing pin
 
* 2.54 mm spacing pin
  
==使用方法==
+
==How To==
===连接===
+
===Connection===
*连接到Tiny4412 SDK (1506)
+
*Connect Tiny4412 SDK (1506)
::GND:  接地
+
::GND:  Ground
::VCC:  接5V
+
::VCC:  5V
::SDA: I2C SDA
+
::SDA: I2C SDA
::SCL: I2C SCL
+
::SCL: I2C SCL
  
===Linux下的C示例===
+
===Code Sample in C Under Linux===
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
 
#include <stdio.h>
 
#include <stdio.h>
Line 59: Line 59:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
===编译并运行示例===
+
===Compile and Run===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
git clone http://github.com/friendlyarm/fa-hardware.git
 
git clone http://github.com/friendlyarm/fa-hardware.git
Line 67: Line 67:
 
make
 
make
 
</syntaxhighlight>
 
</syntaxhighlight>
将编译生成的LCD1602通过ftp上传到开发板上运行即可测试。
+
Copy your compiled bin to your board and you are ready to go.
  
 
==相关资料==
 
==相关资料==

Revision as of 08:09, 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 on this module, 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 Features

  • I2C interface. It can display characters, and turn on and off back light
  • 2.54 mm spacing pin

3 How To

3.1 Connection

  • Connect Tiny4412 SDK (1506)
GND: Ground
VCC: 5V
SDA: I2C SDA
SCL: I2C SCL

3.2 Code Sample in C Under Linux

#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 Compile and Run

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

Copy your compiled bin to your board and you are ready to go.

4 相关资料