Casil LED Backlit 16x2 LCD Display Module Project
An easy project using the Casil OPTO1156GTW-N I2C controlled LED Backlit 16x2 LCD Display Module that will work with mostly existing code.
Components and supplies
Jumper wires (generic)
Casil OPTO1156GTW-N 16x2 LCD Display Module with LED Back Light
Arduino Uno SMD Rev 3, PN: A000073
15 Ohms 1/4W Carbon Film Axial Resistor
1uF 25VDC Dipped Radial Tantalum Capacitor
28AWG 14-Wire Ribbon Cable
10K Ohm 1/4W Carbon Film Axial Resistor
Breadboard (generic)
SLW14S-1C7LF FFC & FPC Connector, 14P, ZIF, 1mm-Pitch
Tools and machines
Soldering iron (generic)
Solder Wire, Lead Free
Wire Stripper & Cutter, 32-20 AWG / 0.05-0.5mm² Solid & Stranded Wires
Project description
Code
LCD_ST7032.h subroutine program to interface with the LCD Display module.
c_cpp
1//------------------------------------------------------------------------------------------- 2// LCD_ST7032.h - Arduino i2c master library for LCD ST7032 3// Olav Kallhovd sept2017 4// 5// Tested Module : ERC1602-4, EASTRISING TECHNOLOGY CO,.LTD. 6// Drive IC : ST7032 7// INTERFACE : I2C 8// VDD : 2.7V-5.5V 9// Tested with MCU : Arduino Uno, Attiny85@1mhz(5.0V), Attiny85@8mhz(5.0V) and ESP8266(3.3V) 10//------------------------------------------------------------------------------------------- 11 12#ifndef LCD_ST7032_h 13#define LCD_ST7032_h 14 15#include <Arduino.h> 16 17#define Write_Address 0x3E //i2c address 18#define CNTRBIT 0x00 //followed by command bytes 19#define CNTRBIT_CO 0x80 //followed by 1 command byte 20#define CNTRBIT_RS 0x40 //after last control byte, followed by DDRAM data byte(s) 21#define CLEAR_DISPLAY 0x01 //Clear display 22#define RETURN_HOME 0x02 //Cursor home to 00H 23#define ENTRY_MODE_SET 0x04 //Sets cursor move direction and specifies display shift. 24#define DISPLAY_ON_OFF 0x08 //display on, cursor on, cursor position on 25#define FUNCTION_SET 0x20 //DL: interface data is 8/4 bits, N: number of line is 2/1 DH: double height font, IS: instruction table select 26#define SET_DDRAM_ADDRESS 0x80 //Set DDRAM address in address counter 27#define CURSOR_OR_DISPLAY_SHIFT 0x10 //Set cursor moving and display shift control bit, and the direction without changing DDRAM data. 28#define SET_CGRAM_ADDRESS 0x40 //Set CGRAM address in address counter 29#define INTERNAL_OSC_FREQ 0x10 //BS=1:1/4 bias, BS=0:1/5 bias, F2~0: adjust internal OSC frequency for FR frequency. 30#define POWER_ICON_BOST_CONTR 0x50 //Ion: ICON display on/off, Bon: set booster circuit on/off, C5,C4: Contrast set 31#define FOLLOWER_CONTROL 0x60 //Fon: set follower circuit on/off, Rab2~0: select follower amplified ratio. 32#define CONTRAST_SET 0x70 //C0-C3: Contrast set 33#define LINE_1_ADR 0x80 34#define LINE_2_ADR 0xC0 35 36// Various flags and masks 37#define ENTRY_MODE_SET_S 0x01 //S: Shift of entire display, see data sheet 38#define ENTRY_MODE_SET_ID 0x02 //I/D : Increment / decrement of DDRAM address (cursor or blink), see data sheet 39#define DISPLAY_ON_OFF_B 0x01 //cursor position on 40#define DISPLAY_ON_OFF_C 0x02 //cursor on 41#define DISPLAY_ON_OFF_D 0x04 //display on 42#define FUNCTION_SET_IS 0x01 //IS: instruction table select 43#define FUNCTION_SET_DH 0x04 //DH: double height font 44#define FUNCTION_SET_N 0x08 //N: number of line is 2/1 45#define FUNCTION_SET_DL 0x10 //DL: interface data is 8/4 bits 46#define CURSOR_OR_DISPLAY_SHIFT_RL 0x04 // 47#define CURSOR_OR_DISPLAY_SHIFT_SC 0x08 // 48#define INTERNAL_OSC_FREQ_F0 0x01 //F2~0: adjust internal OSC frequency for FR frequency. 49#define INTERNAL_OSC_FREQ_F1 0x02 //F2~0: adjust internal OSC frequency for FR frequency. 50#define INTERNAL_OSC_FREQ_F2 0x04 //F2~0: adjust internal OSC frequency for FR frequency. 51#define INTERNAL_OSC_FREQ_BS 0x08 //BS=1:1/4 bias (BS=0:1/5 bias) 52#define POWER_ICON_BOST_CONTR_Bon 0x04 //Ion: ICON display on/off 53#define POWER_ICON_BOST_CONTR_Ion 0x08 //Bon: set booster circuit on/off 54#define FOLLOWER_CONTROL_Rab0 0x01 //Rab2~0: select follower amplified ratio 55#define FOLLOWER_CONTROL_Rab1 0x02 //Rab2~0: select follower amplified ratio 56#define FOLLOWER_CONTROL_Rab2 0x04 //Rab2~0: select follower amplified ratio 57#define FOLLOWER_CONTROL_Fon 0x08 //Fon: set follower circuit on/off 58 59#define CONTRAST_MAX 0x3F //limit range max value (0x00 - 0x3F) 60#define CONTRAST_MIN 0x10 //limit range min value (0x00 - 0x3F) 61#define WRITE_DELAY_MS 30 //see data sheet 62#define HOME_CLEAR_DELAY_MS 1200 //see data sheet 63 64class LCD_ST7032: public Print 65{ 66 public: 67 LCD_ST7032(); 68 void begin(); 69 void clear(); 70 void home(); 71 void display(); 72 void noDisplay(); 73 void setCursor(uint8_t line, uint8_t pos); 74 void cursor(); 75 void noCursor(); 76 void blink(); 77 void noBlink(); 78 void setcontrast(int val); 79 void adjcontrast(int val); 80 uint8_t getcontrast(); 81 virtual size_t write(uint8_t chr); 82 83 protected: 84 void Write_Instruction(uint8_t cmd); 85 void Write_Data(uint8_t data); 86 uint8_t displayOnOffSetting = (DISPLAY_ON_OFF | DISPLAY_ON_OFF_D); 87 uint8_t contrast = 0x18; 88}; 89 90#endif 91
LCD_ST7032.h subroutine program to interface with the LCD Display module.
c_cpp
1//------------------------------------------------------------------------------------------- 2// LCD_ST7032.h - Arduino i2c master library for LCD ST7032 3// Olav Kallhovd sept2017 4// 5// Tested Module : ERC1602-4, EASTRISING TECHNOLOGY CO,.LTD. 6// Drive IC : ST7032 7// INTERFACE : I2C 8// VDD : 2.7V-5.5V 9// Tested with MCU : Arduino Uno, Attiny85@1mhz(5.0V), Attiny85@8mhz(5.0V) and ESP8266(3.3V) 10//------------------------------------------------------------------------------------------- 11 12#ifndef LCD_ST7032_h 13#define LCD_ST7032_h 14 15#include <Arduino.h> 16 17#define Write_Address 0x3E //i2c address 18#define CNTRBIT 0x00 //followed by command bytes 19#define CNTRBIT_CO 0x80 //followed by 1 command byte 20#define CNTRBIT_RS 0x40 //after last control byte, followed by DDRAM data byte(s) 21#define CLEAR_DISPLAY 0x01 //Clear display 22#define RETURN_HOME 0x02 //Cursor home to 00H 23#define ENTRY_MODE_SET 0x04 //Sets cursor move direction and specifies display shift. 24#define DISPLAY_ON_OFF 0x08 //display on, cursor on, cursor position on 25#define FUNCTION_SET 0x20 //DL: interface data is 8/4 bits, N: number of line is 2/1 DH: double height font, IS: instruction table select 26#define SET_DDRAM_ADDRESS 0x80 //Set DDRAM address in address counter 27#define CURSOR_OR_DISPLAY_SHIFT 0x10 //Set cursor moving and display shift control bit, and the direction without changing DDRAM data. 28#define SET_CGRAM_ADDRESS 0x40 //Set CGRAM address in address counter 29#define INTERNAL_OSC_FREQ 0x10 //BS=1:1/4 bias, BS=0:1/5 bias, F2~0: adjust internal OSC frequency for FR frequency. 30#define POWER_ICON_BOST_CONTR 0x50 //Ion: ICON display on/off, Bon: set booster circuit on/off, C5,C4: Contrast set 31#define FOLLOWER_CONTROL 0x60 //Fon: set follower circuit on/off, Rab2~0: select follower amplified ratio. 32#define CONTRAST_SET 0x70 //C0-C3: Contrast set 33#define LINE_1_ADR 0x80 34#define LINE_2_ADR 0xC0 35 36// Various flags and masks 37#define ENTRY_MODE_SET_S 0x01 //S: Shift of entire display, see data sheet 38#define ENTRY_MODE_SET_ID 0x02 //I/D : Increment / decrement of DDRAM address (cursor or blink), see data sheet 39#define DISPLAY_ON_OFF_B 0x01 //cursor position on 40#define DISPLAY_ON_OFF_C 0x02 //cursor on 41#define DISPLAY_ON_OFF_D 0x04 //display on 42#define FUNCTION_SET_IS 0x01 //IS: instruction table select 43#define FUNCTION_SET_DH 0x04 //DH: double height font 44#define FUNCTION_SET_N 0x08 //N: number of line is 2/1 45#define FUNCTION_SET_DL 0x10 //DL: interface data is 8/4 bits 46#define CURSOR_OR_DISPLAY_SHIFT_RL 0x04 // 47#define CURSOR_OR_DISPLAY_SHIFT_SC 0x08 // 48#define INTERNAL_OSC_FREQ_F0 0x01 //F2~0: adjust internal OSC frequency for FR frequency. 49#define INTERNAL_OSC_FREQ_F1 0x02 //F2~0: adjust internal OSC frequency for FR frequency. 50#define INTERNAL_OSC_FREQ_F2 0x04 //F2~0: adjust internal OSC frequency for FR frequency. 51#define INTERNAL_OSC_FREQ_BS 0x08 //BS=1:1/4 bias (BS=0:1/5 bias) 52#define POWER_ICON_BOST_CONTR_Bon 0x04 //Ion: ICON display on/off 53#define POWER_ICON_BOST_CONTR_Ion 0x08 //Bon: set booster circuit on/off 54#define FOLLOWER_CONTROL_Rab0 0x01 //Rab2~0: select follower amplified ratio 55#define FOLLOWER_CONTROL_Rab1 0x02 //Rab2~0: select follower amplified ratio 56#define FOLLOWER_CONTROL_Rab2 0x04 //Rab2~0: select follower amplified ratio 57#define FOLLOWER_CONTROL_Fon 0x08 //Fon: set follower circuit on/off 58 59#define CONTRAST_MAX 0x3F //limit range max value (0x00 - 0x3F) 60#define CONTRAST_MIN 0x10 //limit range min value (0x00 - 0x3F) 61#define WRITE_DELAY_MS 30 //see data sheet 62#define HOME_CLEAR_DELAY_MS 1200 //see data sheet 63 64class LCD_ST7032: public Print 65{ 66 public: 67 LCD_ST7032(); 68 void begin(); 69 void clear(); 70 void home(); 71 void display(); 72 void noDisplay(); 73 void setCursor(uint8_t line, uint8_t pos); 74 void cursor(); 75 void noCursor(); 76 void blink(); 77 void noBlink(); 78 void setcontrast(int val); 79 void adjcontrast(int val); 80 uint8_t getcontrast(); 81 virtual size_t write(uint8_t chr); 82 83 protected: 84 void Write_Instruction(uint8_t cmd); 85 void Write_Data(uint8_t data); 86 uint8_t displayOnOffSetting = (DISPLAY_ON_OFF | DISPLAY_ON_OFF_D); 87 uint8_t contrast = 0x18; 88}; 89 90#endif 91
Main program to control the LCD Display Module with the Arduino Uno
c_cpp
This main program makes use of the LCD_ST7032.h subroutine driver to interface with the LCD display
1//------------------------------------------------------------------------------------------- 2// Tested Module : OPTO1156GTW-N, CASIL SEMICONDUCTOR LTD. 3// Drive IC : ST7032 4// INTERFACE : I2C 5// VDD : 3.3V 6// Tested with MCU : Arduino Uno 7//------------------------------------------------------------------------------------------- 8 9#include <LCD_ST7032.h> 10 11LCD_ST7032 lcd; 12 13void setup() { 14 lcd.begin(); 15 lcd.setcontrast(63); //contrast value range is 0-63 16} 17 18void loop() { 19 20 // Text for first line... 21 lcd.setCursor(0,0); //LINE 1, ADDRESS 0 22 lcd.print("16X2 LCD DISPLAY"); 23 24 // Text for second line... 25 lcd.setCursor(1, 1); //LINE 2, ADDRESS 1 26 lcd.print("W/LED BACKLIGHT"); 27} 28
Downloadable files
Schematic diagram for Interfacing the Casil LCD Display to the Arduino Uno
Wire up as shown with with all component mentioned in the parts list
Schematic diagram for Interfacing the Casil LCD Display to the Arduino Uno
Schematic diagram for Interfacing the Casil LCD Display to the Arduino Uno
Wire up as shown with with all component mentioned in the parts list
Schematic diagram for Interfacing the Casil LCD Display to the Arduino Uno
Comments
Only logged in users can leave comments