EP-0058: Difference between revisions

From 52Pi Wiki
Jump to navigation Jump to search
m (Yoyojacky moved page RGB LCD1602 SKU:EP-0058 to EP-0058)
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
=RPI RGB LCD1602=
=RGB LCD 1602 =
==Description==
==Description==
It's a LCD display which can show two lines and 16 characters on it. and  it easy to use a blue and white 16x2 Character LCD.<br>
This RGB 1602 full color module is based on i2c protocol, with 5 input buttons.<br>
It's based on I2c protocol and it can communicate with your Pi with less wire. <br>
The background  light can be changed by coordinate PWM, and it also support Raspberry Pi 3B. <br>
With this in mind, we wanted to make it easier for people to get these LCD into their projects so we devised a Pi plate that lets you control a 16x2 Character LCD,<br>
You have  three colors to chose, RBG(red,green, blue), you can change it as you will freely.<br>
up to 3 led pins(RGB backlight) AND 5 keypad pins with  pull-up resister using only the two I2C pins on the R-Pi! <br>
You can just plug it into your Raspberry Pi and  drive it through i2c protocol control the mcp23016 expand IO port. <br>
The best part is you don't really lose those two pins either, since you can stick i2c-based sensors, RTCs, etc and have them share the I2C bus.<br>
It reduced occupation of the GPIO Pins and you can use wiringPi's lcd library to control it.  
This is a super slick way to add a display without all the wiring hassle.
This pi plate is perfect for when you want to build a stand-alone project with its own user interface. <br>
The 4 directional buttons plus select button allows basic control without having to attach a bulky computer.<br>
The plate is designed for both Revision 1 and Revision 2 Raspberry Pi's. It uses the I2C (SDA/SCL) pins, RGB backlight is controlled by Raspberry Pi GPIO pin and you can make it as breath light with softPWM. <br>
To keep them from shorting against the metal, a piece of electrical tape must be placed onto the USB ports.<br>
----
----
==Compatibility List==
* Compatibility
{| class="wikitable" style="text-align: center;"
|-
!Platform !! Screen and driver board !! Notes
|-
|Raspberry Pi 3 Model B Plus||WIP||
|-
|Raspberry Pi 3 Model B|| √||
|-
|Raspberry Pi 2 Model B|| √||
|-
|}


==Feature==
==Features==
*Display construction: 16 Characters * 2 Lines
*Designed for Raspberry Pi, support Raspberry Pi 3 mode B
*Dimensions: 5.74cm × 8.24cm
*Three optional RGB(red,green,blue) backlight.
*Comes with a 16x2 Blue & White LCD
*Three independly coordinate pins can be use.
*Plug and play with any Raspberry Pi
*High quilaty 16x2 display
*Uses only the I2C (SDA/SCL) pins
*size 2.95X4.35(WXH)mm
*This board/chip uses I2C 7-bit address 0x20
*Builtin HD44780 controller can be attached to MCU directly
*RBG backlight
*Main Controller driver chip is SplC780, can be compatible with other main controller such as 0066(SAMSUNG),SPLC780(SUNPLUS) and so on<br>
*Pluggable LCD1602 module
*Character generator ROM can provide 192 different characters. (5x7 can be 160  or  5x10 can be 32)
*64bit custom RAM, can provide 8 8x8 dot characters or 2/4  5x11 dot characters
*80 byte RAM
* MCP23017 IO expand port.
* Open source refference : [http://wiringpi.com/extensions/i2c-mcp23008-mcp23017/]
* 5 customized button can be defined to different functions.
----
==Product Details==
{| width="300" cellspacing="0" cellpadding="0" border="1"
|-
! align="center" scope="col" style="width: 40%"  |  type
! align="center" scope="col" | value
|-
| align="center" scope="row" | work voltage
| align="center" | 5V
|-
| align="center" scope="row" | backlight
| align="center" | red green blue
|-
|align="center" scope="row"  | maximum current
| align="center" | 60mA
|-
| align="center" scope="row" | LCD display type
| align="center" | STN
|-
| align="center" scope="row" | work temprature
| align="center" | 0~+50℃
|-
| align="center" scope="row" | storage temprature
| align="center" | -20~+70℃
|-
| align="center" scope="row" | scale
| align="center" | 82x58(mm)
|-
| align="center"  scope="row" | display scale
| align="center" | 64.5x16(mm)
|-
| align="center" scope="row" | character number
| align="center" | 16x2
|-
| align="center" scope="row" | control chip
| align="center" | SplC780
|-
| align="center" scope="row" | mount hole
| align="center" | 75.0*31.0/ 2.8mm
|-
| align="center" scope="row" | LCD pixel
| align="center" | 0.55*0.65mm
|-
| align="center" scope="row" | connector
| align="center" | 18PIN,PH2.54,1.0mm
|}
----
 
==Overview==
{|
|[[Image:RGB1602_p1.JPG|thumb|left|300px]]
|[[Image:RGB1602_p4.JPG|thumb|none|300px]]
|[[Image:RGB1602_p5.JPG|thumb|none|300px]]
|}
<br style="clear:both;">
{|
|[[Image:RGB1602_p3.JPG|thumb|none|300px]]
|[[Image:Rgb1602 01.JPG|thumb|none|300px]]
|[[File:show2.JPG|thumb|none|300px]]
|}
<br style="clear:both;">
----
----


==Presentation==
==Schematic==
[[File: 160201.jpg|thumb|left|300px]]
[[Image:1602test1.png|400px]]
[[File: 160202.jpg|thumb|left|300px]]
<br style="clear:both;">
[[File: 160203.jpg|thumb|left|300px]]
----
<br style="clear:both;" >
==LCD module scale==
{|
|[[Image:rgb1602_show3.JPG|thumb|left|300px]]
|[[Image:1602RGB_dimention.png|thumb|none|300px]]
|}
<br style="clear:both;">
----
----
==Package includes==
==RGB1602 pin description==
* 1x RPI 16x2 LCD + Keypad Kit
{| width="400" cellspacing="0" border="1" cellspacing="0"
|-
! align="center" scope="col" style="width: 40%" | pin number 
! align="center" scope="col" | chart
! align="center" scope="col" | function
|-
| align="center" scope="row" | 1
| align="center" | Vss
| align="center" | GND
|-
| align="center" scope="row" | 2
| align="center" | Vdd
| align="center" | Voltage supply
|-
|align="center" scope="row" | 3
| align="center" | Vo
| align="center" | LCD contrast
|-
| align="center" scope="row" | 4
| align="center" | RS
| align="center" | register select
|-
| align="center" scope="row" | 5
| align="center" | R/W
| align="center" | read or write select
|-
| align="center" scope="row" | 6
| align="center" | E
| align="center" | enable
|-
| align="center" scope="row" | 7
| align="center" | DB0
| align="center" | data pin 0
|-
| align="center" scope="row" | 8
| align="center" | DB1
| align="center" | data pin 1
|-
| align="center" scope="row" | 9
| align="center" | DB2
| align="center" | data pin 2
|-
| align="center" scope="row" | 10
| align="center" | DB3
| align="center" | data pin 3
|-
| align="center" scope="row" | 11
| align="center" | DB4
| align="center" | data pin 4
|-
| align="center" scope="row" | 12
| align="center" | DB5
| align="center" | data pin 5
|-
| align="center" scope="row" | 13
| align="center" | DB6
| align="center" | data pin 6
|-
| align="center" scope="row" | 14
| align="center" | DB7
| align="center" | daata pin 7
|-
| align="center" scope="row" | 15
| align="center" | LEDA
| align="center" | LED backlight voltage supply
|-
| align="center" scope="row" | 16
| align="center" | LEDR
| align="center" | red LED backlight control
|-
| align="center" scope="row" | 17
| align="center" | LEDG
| align="center" | green LED backlight control
|-
| align="center" scope="row" | 18
| align="center" | LEDB
| align="center" | blue LED backlight control
|-
|}
[[Image:1602_RGB_test3.png|thumb|left|300px]]
<br style="clear:both;">
----
----
==How to use==
 
*Setup your Pi with I2C tool.<br>
==How to make it work==
<code> sudo apt-get install python-smbus </code><br>
*If it's the first time for you to use Raspberry Pi, please make sure the I2C interface is enabled.  
<code> sudo apt-get install i2c-tools </code><br>
*You also need to install wiringPi library. This page will show you how to install wiringPi. http://wiringpi.com/download-and-install/
<code>sudo i2cdetect -y 0 (if you are using a version 1 Raspberry Pi) </code><br>
*If you are done install the wiringPi and enabling I2C interface, type the following code in the console to build a .c file
<code>sudo i2cdetect -y 1 (if you are using a version 2 Raspberry Pi) </code><br>
<code>sudo vim.tiny lcd1602.c</code>
*i2c-tools isn't strictly required, but it's a useful package since you can use it to scan for any I2C or SMBus devices connected to your board.<br>
[[Image:1602_tech1.png|thumb|left|300px]]
If you know something is connected, but you don't know it's 7-bit I2C address, this library has a great little tool to help you find it.<br>
<br style="clear:both;">
[[File:I2c.jpg|thumb|left|300px]]
*Copy and paste the following [[#tech1|demo code]] into lcd1602.c
[[File:1602_tech2.png|thumb|left|300px]]
<br style="clear:both;">
*Under the vim.tiny editor, type ":", then type "wq" and press "enter" to save the lcd1602.c file and exit editor
[[File:1602_tech3.png|thumb|left|300px]]
<br style="clear:both;">
*Next you need to compile the code using gcc. <br>
Type <code>gcc lcd1602.c -lwiringPi /home/pi/wiringPi/devLib/lcd.o -o lcd1602</code> in the console to compile.<br>
[[File:1602_tech5.png|thumb|left|300px]]
<br style="clear:both;">
*You should find an executable file named "lcd1602" if the last step was completed. <br>
Type the following code <code>sudo modprobe i2c-dev</code> to load the I2C interface
[[File:1602_tech6.png|thumb|left|300px]]
<br style="clear:both;">
[[File:1602_tech8.png|thumb|left|300px]]
<br style="clear:both;">
*Lastly, type <code>sudo ./lcd1602</code> , and the module will be displaying the demo text, as the following photo shows.
[[File:1602_tech9.png|thumb|left|300px]]
<br style="clear:both;">
[[File:show2.JPG|thumb|left|300px]]
<br style="clear:both;">
*This is a gif showing the different backlight color
[[File:show1.gif|thumb|left|400px]]
<br style="clear:both;">
<br style="clear:both;">
*Install  git-core and get wiringPi library. <br>
 
<code> sudo apt-get install git-core </code><br>
==Demo Code ==
<code> git clone git://git.drogon.net/wiringPi</code><br>
<div id="tech1"></div>
<code> cd wiringPi</code><br>
<code> ./build</code><br>
*Check wiringPi  function and version:<br>
<code> gpio -v</code><br>
<code> gpio readall</code><br>
[[File:Gpio.jpg|thumb|left|300px]]
<br style="clear:both;" >
*Enable  I2C interface in your Pi by editing /etc/modules file and add two lines as following: <br>
<code> sudo nano /etc/modules </code><br>
<pre>
i2c-bcm2708
i2c-dev
</pre><br>
* Delete blacklist in /etc/modprobe.d/raspi-blacklist.conf, you can just use "#" to comment it.<br>
<code> sudo nano /etc/modprobe.d/raspi-blacklist.conf</code><br>
<pre>
blacklist spi-bcm2708
blacklist i2c-bcm2708
</pre><br>
*Finally, reboot your Pi.<br>
*Create a file called whatever you want but with .c  as prefix: <br>
<code> sudo vim.tiny  mylcd1602.c </code><br>
<pre>
<pre>
#include <stdio.h>                                                                      
#include <stdio.h>                                                           //include standard input output head file                                                           
#include <wiringPi.h>                                                            
#include <wiringPi.h>                                                         //include wiringpi                                                   
#include <mcp23017.h>                                                         
#include <mcp23017.h>                                                        //include mcp23017 control head file                                       
#include <lcd.h>                                                          
#include <lcd.h>                                                             //include LCD control head file                                                 
#include <softPwm.h>                                                          //include PWM control head file
int main()
int main()
{
{
        int display,i,count;                                                    
long value=0;     
        wiringPiSetup();                                                        
int rand_num;
        mcp23017Setup (100, 0x20);                                              
int value_blue;                                                      //the blue backlight brightness
        printf ("Raspberry Pi - MCP23017 Test\n");
int value_red;                                                        //the red backlight brightness
        for(i=0;i<16;i++)
int value_green;                                                      //the green backlight brightness
          pinMode(100+i,OUTPUT);                                                 
int display,i,count;                                                
        digitalWrite(107,1);                                                     
wiringPiSetup();                                                     //init wiringPi                                                   
        digitalWrite(101,0);                                                      
mcp23017Setup (100, 0x20);                                           //init mcp23017 chip I2C address: 0x20,the first pin number: 100                                         
        display=lcdInit(2,16,4,100,102,103,104,105,106,0,0,0,0);              
printf ("Raspberry Pi - MCP23017 Test\n");                           //print information
        lcdHome(display);                                                        
for(i=0;i<16;i++)                          
        lcdClear(display);                                                              
pinMode(100+i,OUTPUT);                                                //set pin 100 - 115 as output                         
        lcdPosition(display,0,0);                                              
digitalWrite(101,0);                                                 //set pin 101 low voltage                             
        lcdPuts(display,"Hello World");                                        
display=lcdInit(2,16,4,100,102,103,104,105,106,0,0,0,0);     //lcd init 2*16,4 bit control,use 100,101,102,103,104 pin as control pin       
        while(1)
lcdHome(display);                                                     //reset cursor 
         {
lcdClear(display);                                                   //clear screen 
                lcdPosition(display,0,1);                                                                                      
lcdPosition(display,0,0);                                             //set display location (0,0) 
                lcdPrintf(display,"%d",count++);                                        
lcdPuts(display,"Hello World");                                       //print string "Hello World"
                delay(300);                                                          
lcdPosition(display,0,1);                                            //set display location(0,1) 
                printf("lcd1602\n");
lcdPuts(display,"www.52pi.net");                                  //print string "www.52pi.net"
        }
pinMode(0, OUTPUT);                                                  //set Raspberry pi pin 0 as output 
pinMode(2, OUTPUT);                                                  //set Raspberry Pi pin 2 as output 
pinMode(3, OUTPUT);                                                  //set Raspberry Pi pin 3 as output
softPwmCreate (3, 50, 100);                                          //set soft PWM pin 3 PWM scale (0-100) original 50
softPwmCreate (2, 50, 100);                                          //set soft PWM pin 2 PWM scale (0-100) original 50
softPwmCreate (0, 50, 100);                                          //set soft PWM pin 0 PWM scale (0-100) original 50
while(1)                                                                     //always display
{     
 
delay(200);                                                            //delay 200ms
         value_red=(value<100)?value:0;                                        //0-100 red change
value_green=(value>100&&value<200)?(value-100):0;                      //100-200 green change
value_blue=(value>200)?(value-200):0;                                  //200-300 blue change       
if(value>300)                                                          //>300 random colour
{
value_red=rand()%100;
value_green=rand()%100;
value_blue=rand()%100;
}
//rand_num=rand();
softPwmWrite (3,value_red);                                            //soft PWM control red backlight
softPwmWrite (2,value_green);                                          //soft PWM control green backlight
softPwmWrite (0,value_blue);                                            //soft PWM control blue backlight
 
value++;
if(value>900)                                                          //if value >900 return
{                 
value=0;
}
lcdPosition(display,13,1);                                                
lcdPrintf(display,"%d",value);                                           //print number value
//value_blue=0;
}
}
}
</pre><br>
 
*Compile it with gcc, and run it. <br>
</pre>
<code> sudo gcc  mylcd1602.c  /home/pi/wiringPi/devLib/lcd.o  -lwiringPi  -o  mylcd1602 </code><br>
<code> sudo ./mylcd1602 </code><br>
[[File: 160203.jpg|thumb|left|300px]]
<br style="clear:both;" >
----
----
==Attachment==
<div id="tech1"></div>
<br>[[media:TC1602A-01T.pdf|LCD manuals]]
<br>[[media:Lcd1602_rgb.zip|demo code]]

Revision as of 19:55, 27 August 2021

RGB LCD 1602

Description

This RGB 1602 full color module is based on i2c protocol, with 5 input buttons.
The background light can be changed by coordinate PWM, and it also support Raspberry Pi 3B.
You have three colors to chose, RBG(red,green, blue), you can change it as you will freely.
You can just plug it into your Raspberry Pi and drive it through i2c protocol control the mcp23016 expand IO port.
It reduced occupation of the GPIO Pins and you can use wiringPi's lcd library to control it.


Compatibility List

  • Compatibility
Platform Screen and driver board Notes
Raspberry Pi 3 Model B Plus WIP
Raspberry Pi 3 Model B
Raspberry Pi 2 Model B

Features

  • Designed for Raspberry Pi, support Raspberry Pi 3 mode B
  • Three optional RGB(red,green,blue) backlight.
  • Three independly coordinate pins can be use.
  • High quilaty 16x2 display
  • size 2.95X4.35(WXH)mm
  • Builtin HD44780 controller can be attached to MCU directly
  • Main Controller driver chip is SplC780, can be compatible with other main controller such as 0066(SAMSUNG),SPLC780(SUNPLUS) and so on
  • Character generator ROM can provide 192 different characters. (5x7 can be 160 or 5x10 can be 32)
  • 64bit custom RAM, can provide 8 8x8 dot characters or 2/4 5x11 dot characters
  • 80 byte RAM
  • MCP23017 IO expand port.
  • Open source refference : [1]
  • 5 customized button can be defined to different functions.

Product Details

type value
work voltage 5V
backlight red green blue
maximum current 60mA
LCD display type STN
work temprature 0~+50℃
storage temprature -20~+70℃
scale 82x58(mm)
display scale 64.5x16(mm)
character number 16x2
control chip SplC780
mount hole 75.0*31.0/ 2.8mm
LCD pixel 0.55*0.65mm
connector 18PIN,PH2.54,1.0mm

Overview




Schematic

File:1602test1.png


LCD module scale



RGB1602 pin description

pin number chart function
1 Vss GND
2 Vdd Voltage supply
3 Vo LCD contrast
4 RS register select
5 R/W read or write select
6 E enable
7 DB0 data pin 0
8 DB1 data pin 1
9 DB2 data pin 2
10 DB3 data pin 3
11 DB4 data pin 4
12 DB5 data pin 5
13 DB6 data pin 6
14 DB7 daata pin 7
15 LEDA LED backlight voltage supply
16 LEDR red LED backlight control
17 LEDG green LED backlight control
18 LEDB blue LED backlight control



How to make it work

  • If it's the first time for you to use Raspberry Pi, please make sure the I2C interface is enabled.
  • You also need to install wiringPi library. This page will show you how to install wiringPi. http://wiringpi.com/download-and-install/
  • If you are done install the wiringPi and enabling I2C interface, type the following code in the console to build a .c file

sudo vim.tiny lcd1602.c


  • Copy and paste the following demo code into lcd1602.c


  • Under the vim.tiny editor, type ":", then type "wq" and press "enter" to save the lcd1602.c file and exit editor


  • Next you need to compile the code using gcc.

Type gcc lcd1602.c -lwiringPi /home/pi/wiringPi/devLib/lcd.o -o lcd1602 in the console to compile.


  • You should find an executable file named "lcd1602" if the last step was completed.

Type the following code sudo modprobe i2c-dev to load the I2C interface



  • Lastly, type sudo ./lcd1602 , and the module will be displaying the demo text, as the following photo shows.



  • This is a gif showing the different backlight color


Demo Code

#include <stdio.h>                                                            //include standard input output head file                                                            
#include <wiringPi.h>                                                         //include wiringpi                                                     
#include <mcp23017.h>                                                         //include mcp23017 control head file                                         
#include <lcd.h>                                                              //include LCD control head file                                                   
#include <softPwm.h>                                                          //include PWM control head file
int main()
{
	long value=0;       
	int rand_num;	 
	int value_blue;                                                       //the blue backlight brightness
	int value_red;                                                        //the red backlight brightness
	int value_green;                                                      //the green backlight brightness
	int display,i,count;                                                 
	wiringPiSetup();                                                      //init wiringPi                                                    
	mcp23017Setup (100, 0x20);                                            //init mcp23017 chip I2C address: 0x20,the first pin number: 100                                          
	printf ("Raspberry Pi - MCP23017 Test\n");                            //print information
	for(i=0;i<16;i++)                            
	pinMode(100+i,OUTPUT);                                                //set pin 100 - 115 as output                          
	digitalWrite(101,0);                                                  //set pin 101 low voltage                              
	display=lcdInit(2,16,4,100,102,103,104,105,106,0,0,0,0);      //lcd init 2*16,4 bit control,use 100,101,102,103,104 pin as control pin         
	lcdHome(display);                                                     //reset cursor  
	lcdClear(display);                                                    //clear screen   
	lcdPosition(display,0,0);                                             //set display location (0,0)   
	lcdPuts(display,"Hello World");                                       //print string "Hello World"
	lcdPosition(display,0,1);                                             //set display location(0,1)  
	lcdPuts(display,"www.52pi.net");                            	      //print string "www.52pi.net"		
	pinMode(0, OUTPUT);                                                   //set Raspberry pi pin 0 as output   
	pinMode(2, OUTPUT);                                                   //set Raspberry Pi pin 2 as output  
	pinMode(3, OUTPUT);                                                   //set Raspberry Pi pin 3 as output
	softPwmCreate (3, 50, 100);                                           //set soft PWM pin 3 PWM scale (0-100) original 50
	softPwmCreate (2, 50, 100);                                           //set soft PWM pin 2 PWM scale (0-100) original 50
	softPwmCreate (0, 50, 100);                                           //set soft PWM pin 0 PWM scale (0-100) original 50
while(1)                                                                      //always display
{       
  
	delay(200);                                                            //delay 200ms
        value_red=(value<100)?value:0;                                         //0-100 red change
	value_green=(value>100&&value<200)?(value-100):0;                      //100-200 green change 
	value_blue=(value>200)?(value-200):0;                                  //200-300 blue change        
	if(value>300)                                                          //>300 random colour
	{
		value_red=rand()%100;
		value_green=rand()%100;
		value_blue=rand()%100;
	}
	//rand_num=rand();
	softPwmWrite (3,value_red);                                             //soft PWM control red backlight
	softPwmWrite (2,value_green);                                           //soft PWM control green backlight
	softPwmWrite (0,value_blue);                                            //soft PWM control blue backlight

	value++;
	if(value>900)                                                           //if value >900 return
	{                   
		value=0;
	}
		
	lcdPosition(display,13,1);                                                 
	lcdPrintf(display,"%d",value);                                           //print number value
	//value_blue=0;
		
	}
}


Attachment


LCD manuals
demo code