RGB 1602(English)

From 52Pi Wiki
Jump to navigation Jump to search

Raspberry Pi RGB1602 LCD Module

Description

We made some improvements based on the former LCD1602 module, so that this RGB1602 is now able to switch different backlight colors, and it has five built-in function keys.
RGB1602 display module has two rows and sixteen columns which shows 16*2 characters.
The backlight can switch between plenty of colors such as red, green, blue, pink and yellow, etc.
The module uses a MCP23017 port expander chip in order to expand Raspberry Pi's IO pins and decrease the amount of IO pins the user needs to operate the display module.
This module requires only I2C interface and three IO pins to control the display and 5 function keys. It is reliable and easy-to-setup.
The screen itself could be unmounted individually. After unmounting, the screen can be used on a bread board for other customized usages.

Technical 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


RGB1602 p1.JPG
RGB1602 p4.JPG
RGB1602 p5.JPG
RGB1602 p3.JPG
Rgb1602 01.JPG

Schematic

1602test1.png

LCD module scale


Rgb1602 show3.JPG
1602RGB dimention.png

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


1602 RGB test3.png

Learn

sudo vim.tiny lcd1602.c
1602 tech1.png

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

1602 tech2.png

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

1602 tech3.png

  • 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.

1602 tech5.png

  • 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

1602 tech6.png
1602 tech8.png

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

1602 tech9.png
Show2.JPG

  • This is a gif showing the different backlight colors


Show1.gif

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;
		
	}
}

Shop

Attachment


LCD manuals
demo code