20x4 character OLED using Adafruit CharacterOLED library

Hi, this is one of my first Arduino projects, and it's also my first time posting on this forum, so if I've done anything incorrectly or missed something obvious please try to be understanding. I appreciate any help thanks in advance :slight_smile:

I recently purchased a character OLED from Vishay, more specifically, this one :

I'm trying to use the Adafruit Character OLED library, which to the best of my knowledge is a modded LiquidCrystal Library.

It's initially configured for 16x2 display, but I've changed the begin line (for a 20x4 display) as show below :

  pinMode(_rs_pin, OUTPUT);
  pinMode(_rw_pin, OUTPUT);
  pinMode(_enable_pin, OUTPUT);
  
  _displayfunction = LCD_FUNCTIONSET | LCD_4BITMODE;
   
  begin(20, 4);  
}

I've also added a delay after the clear function since the display manufacturer (Vishay) informed me it would be needed :

/********** high level commands, for the user! */
void Adafruit_CharacterOLED::clear()
{
  command(LCD_CLEARDISPLAY);  // clear display, set cursor position to zero
  delayMicroseconds(6200);  // this command takes a long time!
}

So far these are the only changes I've brought to the library. My pinout from my Arduino follows both the instructions by Adafruit relating to the code, and Vishay's datasheet. I am quite confident it is correct and that the problem isn't there.

My display shows off random strings of characters that scramble and flicker. Most of the time these characters are dimmed, as if the display is rapidly refreshing. They change a couple times after the Arduino and screen is powered on, and then they stop changing and stay static.

I was wondering if someone could look over the library, and if they can spot glaring inconsistencies or issues the code I'm using. It's probably not configured properly for the OLED I'm using, and that's where I could use your help.

Thanks for taking the time to read this, and for your help if you can offer any !

Attached will be the OLED datasheet, the .cpp file I've modified for the Adafruit Character OLED library I'm using, the link to the Adafruit pinout instructions I've followed. Let me know if I can provide you with any other information I've used so far.

Adafruit_CharacterOLED.cpp (7.81 KB)

OLED datasheet-compressed.pdf (1 MB)

Somehow I think it might be helpful to look at your actual program code.

Don

Sorry, I should've mentioned. I'm just using the example in the library, with the begin function set for a 20x4 OLED :

/*
 Based on the LiquidCrystal Library - Hello World
 
 Demonstrates the use a Winstar 16x2 OLED display.  These are similar, but
 not quite 100% compatible with the Hitachi HD44780 based LCD displays. 
 
 This sketch prints "Hello OLED World" to the LCD
 and shows the time in seconds since startup.
 
  The circuit:
 * LCD RS pin to digital pin 6
 * LCD R/W pin to digital pin 7
 * LCD Enable pin to digital pin 8
 * LCD D4 pin to digital pin 9
 * LCD D5 pin to digital pin 10
 * LCD D6 pin to digital pin 11
 * LCD D7 pin to digital pin 12

 There is no need for the contrast pot as used in the LCD tutorial
 
 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe
 Library & Example Converted for OLED
 by Bill Earl 30 Jun 2012
 
 This example code is in the public domain.
 */

// include the library code:
#include <Adafruit_CharacterOLED.h>

// initialize the library with the OLED hardware 
// version OLED_Vx and numbers of the interface pins. 
// OLED_V1 = older, OLED_V2 = newer. If 2 doesn't work try 1 ;)
Adafruit_CharacterOLED lcd(OLED_V2, 6, 7, 8, 9, 10, 11, 12);

void setup() 
{
  // Print a message to the LCD.
  lcd.begin(20, 4);
  lcd.print("hello OLED World");
}

void loop() 
{
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}

Hope it helps !