Setting the contrast NHDC0220BiZ-FS(RGB)-FBW-3VM issue
Hello guys,
I am trying to use mentioned display but I am getting quite dark display so I was wondering if the contrast can be set by software.
I have found some registers responsible for contrast settings but my code doesn't work nor shows visible results regarding contrast change.
I am using Seeeduino Xiao module, 10k pull-up ressistors and 1uF capacitors where needed. Display shows text correctly but fails in contrast change.
Any suggestions/help?
Here is my code:
#include <Arduino.h>
#include "ST7036.h"
#include <Wire.h>
//#include <LiquidCrystal_I2C.h>
ST7036 lcd = ST7036 ( 2, 20, 0x78 ); //adresa displeja je 0x78
//LiquidCrystal_I2C lcd(2, 20, 0x78);
byte ContrastL, ContrastH;
#define ICONC 0b01011100
#define Folower 0b01101000
#define ContrastC 0b01110000
void setup ()
{
lcd.init ();
//lcd.setContrast(10);
Wire.begin();
Serial.begin (9600); // Initialise I2C communication as MASTER and serial
Wire.beginTransmission(0x78); // Start I2C Transmission
Wire.write (ICONC); // ICON disp on, Booster on, Contrast high byte (2)
Wire.write (Folower); // Follower circuit internal ON, Amplifier follower ratio
Wire.write (ContrastC); // Contrast low byte (6)
Wire.endTransmission();
}
void loop ()
{
byte i, j, ICON, Contrast, Kontrast;
ICON = ICONC;
Contrast = ContrastC;
Kontrast = 0;
for (j=0; j<2; j++)
{
ICON = ICON + j;
for (i=0; i<16; i++)
{
lcd.clear();
lcd.setCursor (0, 0);
lcd.print ("Kontrast: ");
lcd.print (Kontrast, DEC);
Serial.print ("Kontrast: ");
Serial.println (Kontrast, DEC);
Kontrast++;
delay (500);
}
Contrast = ContrastC;
}
//lcd.print ("A");
delay(500);
}
My attempts to send other commands (Clear display, return home, Display ON/OFF, etc) also fail.
0
-
Hi,
Please review the following example I2C code:#include <Wire.h>
#define RES 0
//Pin A4 = Data
//Pin A5 = Clock
const unsigned char slave = 0x3C;
const unsigned char com = 0;
const unsigned char dat = 0x40;
unsigned char packet[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
char const text1[] = ("Newhaven Display");
char const text2[] = ("LCD Test LN2 ");
char const text3[] = (" CHARACTER TEST ");
char const text4[] = (" LCD Display ");
char const text5[] = ("ABCDEFGHIJKLMOPQ");
char const text6[] = ("RSTUVWXYZabcdefg");
char const text7[] = ("hijklmnopqrstuvw");
char const text8[] = ("<(''<)|| <('')>|");
const char slave2w = 0x78;
const char Comsend = 0x00;
const char Datasend = 0x40;
void command(unsigned char c){
packet[0] = com;
packet[1] = c;
sendpacket(2);
}
void data(unsigned char d){
packet[0] = com;
packet[1] = d;
sendpacket(2);
}
void sendpacket(unsigned char x){
unsigned char ix;
Wire.beginTransmission(slave2w);
for(ix = 0; ix < x; ix++){
Wire.write(packet[ix]);
}
Wire.endTransmission();
}
void output()
{
int i;
command(0x01);
for(i=0;i<16;i++){
data(0x1F);
}
command(0xA0);
for(i=0;i<16;i++){
data(0x1F);
}
/*
command(0x01);
for (i=0;i<16;i++){
data(text1[i]);
}
command(0xA0);
for (i=0;i<16;i++){
data(text2[i]);
}
command(0xC0);
for (i=0;i<16;i++){
data(text3[i]);
}
command(0xE0);
for (i=0;i<16;i++){
data(text4[i]);
}
*/
}
void setup() {
pinMode(RES, OUTPUT);
pinMode(2, OUTPUT);
digitalWrite(2, LOW);
digitalWrite(RES, HIGH);
delay(10);
digitalWrite(RES, LOW);
delay(100);
digitalWrite(RES, HIGH);
Wire.begin();
delay(10);
command(0x2A); //function set (extended command set)
command(0x71); //function selection A, disable internal Vdd regualtor
data(0x5c);
command(0x28); //function set (fundamental command set)
command(0x08); //display off, cursor off, blink off
command(0x2A); //function set (extended command set)
command(0x79); //OLED command set enabled
command(0xD5); //set display clock divide ratio/oscillator frequency
command(0x70); //set display clock divide ratio/oscillator frequency
command(0x78); //OLED command set disabled
command(0x08); //extended function set (2-lines)
command(0x06); //COM SEG direction
command(0x72); //function selection B, disable internal Vdd regualtor
data(0x00); //ROM CGRAM selection
command(0x2A); //function set (extended command set)
command(0x79); //OLED command set enabled
command(0xDA); //set SEG pins hardware configuration
command(0x10); //set SEG pins hardware configuration
command(0xDC); //function selection C
command(0x00); //function selection C
command(0x81); //set contrast control
command(0x7F); //set contrast control
command(0xD9); //set phase length
command(0xF1); //set phase length
command(0xDB); //set VCOMH deselect level
command(0x40); //set VCOMH deselect level
command(0x78); //OLED command set disabled
command(0x28); //function set (fundamental command set)
command(0x01); //clear display
command(0x80); //set DDRAM address to 0x00
command(0x0C); //display ON
delay(100);
}
void loop() {
for(int i = 0x21; i < (0x21+16); i++){
data(i);
}
delay(1000);
}Regards,
0 -
Thanks,
this helped a lot!0
Please sign in to leave a comment.
Comments
2 comments