Saturday, 4 January 2014

Midas 2004 OLED Character Display

Updated 09/01/2014 Arduino IDE V1 Library Support

After playing with its' little brother, the Midas MCOB21605G1V 1602 OLED, I was hoping for a smooth transition to its "Big Brother," the Midas MCOB42005A1V 20x4 character display...

Unfortunately, the previous Arduino OLED libraries gave nothing in the way of a working display.

The Maplin N11QQ product page claim the following...

"Cross-compatible with all applications using HD44780 equivalent chip sets"
"Built around the industry standard HD44780 chipset, this display can be used where ordinary LCDs are meant to go. It can add an attractive finish to home built Arduino, Raspberry Pi or other electronic projects."

This is simply not the case, The RW pin has to be defined (not grounded) and the timings are different. Lack of detail in the datasheet make it hard to initialize the display, no way is this a direct replacement for a HD44780. If the manufacturers of these HD44780 pin compatible displays were more open regarding specs or even provided working libraries for the more popular platforms, they would be far more popular.

Midas MCOB42005A1V 2004 OLED DISPLAY Maplin (N11QQ) £32.99

It's quite hard to identify who actually manufactures a lot of these re-badged OLED displays, as the rear of the display is not often shown. For reference, here is the rear of the Midas PCB... (WinStar?????)

If you look closely under the current model Sticker, you can still see part of the WinStar label ?? After, being re-badged "Midas".


After many hours of messing around, by trying or modifying various Arduino libraries, I finally managed to initialize the display, using Elco Jacobs OLEDFourBit library (thanks Elco). While the library was built around the Arduino 0023 IDE, it can be changed to support V1 upwards, by doing the following:


change: virtual void write(uint8_t);

to: virtual size_t write(uint8_t);


change: #include "WProgram.h"

to: #include "arduino.h"

change: inline void OLEDFourBit::write(uint8_t value) {

to: inline size_t OLEDFourBit::write(uint8_t value) {

I am not sure if the above changes fully work, as when using my LCD Smartie Sketch, the screen would initialize and display. However, the 4th line was glitchy when updating the screen. Also, the clear function seemed not to work as expected often leaving garbage on the 3rd and 4th line.

(The updated OLEDFourBit library works fine on the Leonardo, see below, Observations and Findings and Possible Fix for IDEv1)

Garbage in the lower right half after update/screen change...

Using 0023 IDE and the original OLEDFourBit library my LCD Smartie Sketch worked great with no display problems when updating or changing to a new screen!

Observations and Findings and Possible Fix for IDEv1
It seems a lot harder to initialize 16x2 and 20x4 OLED displays when using Arduino's that rely on a separate serial chip, such as in the Duemilanove and UNO, maybe due to the extra latency?
Using a Leonardo (Amega32u4), which has hardware USB and Serial support, I had no issue initialising the display using the Adafruit_CharacterOLED library, with the exception of removing one line from the "Adafruit_CharacterOLED.cpp" Initialization sequence.

The New version of the Adafruit_CharacterOLED Library now seems to work properly with either the 16x2 or 20x4 OLED displays, regardless of platform. It would seem in order to fix earlier revisions of the 16x2 OLED displays they came to a similar solution as I did, and inadvertently fix the 20x4 displays.

Use the following for the 20x4 OLED

//.......................................... LCDTYPE Selection..............................................
// "OLED_V2" for 16x2 OLED
// "OLED_V1" for 20x4 or early revision 16x2 OLED

// Pin Order:(LCDTYPE, RS, RW, E, D4, D5, D6, D7)

Adafruit_CharacterOLED lcd(OLED_V1, 12, 11, 10, 5, 4, 3, 2);

This may imply the 20x4 are still using an earlier revision of PCB or Firmware?


// 4-Bit initialization sequence from Technobly

write4bits(0x03); // Put back into 8-bit mode


if(_oled_ver == OLED_V2) { // only run extra command for newer displays





Leonardo Changes "Adafruit_CharacterOLED.cpp" 20x4 or 16x4

"//write4bits(0x03); // Put back in 8-bit mode"

Not only that, on the Leonardo I could interchange between the 16x2 or 20x4 OLED display !

It must be noted, the standard Adafruit_CharacterOLED library works well on either platform, when only using the 16x4 OLED!
When using an UNO on the 20x4 OLED display, a lot more things have to be changed to the Initialization sequence.

UNO Changes "Adafruit_CharacterOLED.cpp" 20x4

void Adafruit_CharacterOLED::begin(uint8_t cols, uint8_t lines) {
_numlines = lines;
_currline = 0;

pinMode(_rs_pin, OUTPUT);
pinMode(_rw_pin, OUTPUT);
pinMode(_enable_pin, OUTPUT);

digitalWrite(_rs_pin, LOW);
digitalWrite(_enable_pin, LOW);
digitalWrite(_rw_pin, LOW);

//---------------------------------Initialization 20x4 Part 1---------------------------------------
// On Arduino Duemilanove / UNO,

// Use "delayMicroseconds(100000);" next line down, for Midas/Newhaven/Winstar 20x4 Character


delayMicroseconds(100000); // give it some time to power up


// Now we pull both RS and R/W low to begin commands

for (int i = 0; i < 4; i++) {
pinMode(_data_pins[i], OUTPUT);
digitalWrite(_data_pins[i], LOW);

// Initialization sequence is not quite as documented by Winstar.
// Documented sequence only works on initial power-up.
// An additional step of putting back into 8-bit mode first is
// required to handle a warm-restart.
// In the data sheet, the timing specs are all zeros(!). These have been tested to
// reliably handle both warm & cold starts.
// 4-Bit initialization sequence from Technobly
// Modified by Rupert Hirst

//---------------------------------- Initialization 20x4 Part 2-------------------------------------
// On Arduino Duemilanove / UNO
// Comment out "//write4bits(0x03);" next line down, for Midas/Newhaven/Winstar 20x4 Character OLED
// Use "delayMicroseconds(10000);" for below Settings

//write4bits(0x03); // Put back in 8-bit mode
write4bits(0x02); // Put into 4-bit mode

command(0x08); // Turn Off
command(0x01); // Clear Display
command(0x06); // Set Entry Mode
command(0x02); // Home Cursor
command(0x0C); // Turn On - enable cursor & blink


/********** high level commands, for the user! */

Brightness DIM/FULL Thanks to "Chris O"

Default Brightness

Dimmed Brightness

Helpful Resources

Datasheets (not so helpful)

Jumper Configuration (Bit-bang, Serial Control)

Here is a diagram I made using the data sheet, to clearly show the Serial jumper settings, as a warning I have yet to try the below settings so consider it as untested!!!

Library Resources

Gnat-Stats, Tiny OLED PC Performance Monitor