Child pages
  • Bit-bang Serial Control of Newhaven OLED Character Display
Skip to end of metadata
Go to start of metadata

This page is about implementing a serial bit-bang protocol to control a Newhaven Display International OLED character display.




OLED (Organic Light Emitting Diode) displays offer wider viewing angles, improved brightness and contrast, and are self-illuminating (require no backlight).  Newhaven offers several models of OLED display that use the same version of built-in controller.  The built-in controller offers both serial and a 6800/8080 compatible parallel interface.


The application example mates a dsPIC33FJ256GP710-I/PT with a Newhaven OLED.  The embedded software implements a simple serial bit-bang protocol to control the OLED and display a message.

While this example implementation uses the dsPIC33FJ256GP710-I/PT, it is easily adapted to other Microchip microcontrollers by making device appropriate pin assignments.  The source code could also be used as a reference or ported to other manufacturers microcontroller products.

The Newhaven OLED displays listed in Tables 1 and 2 utilize the same version of built-in controller.  The demonstration source code and accompanying program file can be used without modification to drive the OLED displays listed in Table 1.

Additionally, the Newhaven OLED displays listed in Table 2 are compatible with the embedded source code.  These displays have additional characters on a line, or additional lines and characters, and can be successfully driven with minor changes to the embedded source code.

Part Number


NHD-0216SZW-BY52 line x 16 character, yellow


2 line x 16 character, green


2 line x 16 character, blue


2 line x 16 character, yellow


2 line x 16 character, green

Table 1

Part Number



2 line x 20 character, yellow


2 line x 20 character, green


4 line x 20 character, yellow


4 line x 20 character, green

Table 2


The hardware used in this example is a Newhaven 2x16 OLED character display and the Microchip Explorer 16 DM240001-ND (requires an ICD3 or other programmer/debugger) or DV164037-ND development board with the included Microchip dsPIC33FJ256GP710-I/PT Processor Installation Module (PIM).  The Prototype PICtail Plus Daughter Board AC164126-ND is used to access the port pins brought out on the Explorer 16 board.

Display interface configuration - parallel or serial?

By default, all of the displays listed in Tables 1 and 2 support the 6800 MPU parallel interface*.  Jumper settings are provided in the product data sheet to configure a display to support the 6800 MPU, 8080 MPU, or a serial interface.  Any changes to the jumper connection will require a soldering iron and repositioning/omitting 0 ohm resistors.  The photo's in table 3 clarify the jumper locations on each PCB.  Each photo is applicable to multiple displays indicated in the adjoining list of part numbers.











Table 3.  Jumper Locations

* Newhaven will build-to-suit displays configured for serial or 8080 parallel interface.  Minimum order quantities will apply.  To start the process send an email to


The default build supports a 2x16 display, but any of the displays will actually work with the code built as-is with limitations - the additional characters and lines available in the other display variants will be blank.  Preprocessor directives provide conditional compilation of particular lines of code to accommodate the display variants with messages that take advantage of the available lines and characters.

ZIP file with demonstration source code and hex file can be found at project (this is an MPLAB X project).  Hex file can be found in folder ".../NHD_OLED_bitbang/NHD_OLED_BB.X/dis/default/production/NHD_OLED_BB.X.production.hex".

To build for a particular display comment/uncomment the appropriate prepocessor directive in file nhd_oled_2x16_main_bb.c:

Preprocessor conditional compile directives
#define OLED_2x16     // For two line display has two lines, each line has 16 characters
//#define OLED_2x20     // For two line display, each line has 20 characters
//#define OLED_4x20     // For four line display, each line has 20 characters

The source code displays a message that utilizes the built-in font table and also the custom character capability of the display.  The message displayed, depending upon line count and length:

1st line is “Newhaven OLED…”
2nd line is “From Digi-Key     x”
(Where the “x” is a place holder for a character animation sequence made up of built-in and custom characters “|”, “/”, “-“, and “\”. After a brief delay a custom character clears the display and then the display sequence repeats.)

4 line displays add the following text:
3rd line is "4 lines a r e better"
4th line is "t h a n t w o ....!"

Clock frequency of the dsPIC33FJ is configured for 7.37Mhz.  A different clock frequency will necessitate a change to the software based time delay routine.  Port pins are assigned as follows: RA4 – LCD select,  RF6 – Serial clock, RF7 – Serial data in (data from LCD – this is not implemented), and RF8 – Serial data out (data to LCD).

Project Build and Load 

It is left to the reader to install and familiarize themselves with MPLAB X IDE, the XC16 compiler, and hardware connections from/to the Explorer 16 development board to their display board. 

Expand/copy zip file to desired system location.  Open MPLAB X IDE, connect the hardware to your computer, and open project "NHD_OLED_BB".  Open the project properties to verify hardware and software tool selection matches your installation.  Make and Program device.

Supporting Files

Demo Software

Application Notes

Newhaven App Note; Serial vs. Parallel Interface 

Authors Note

This webpage is a project started and maintained by the applications engineering staff at Digi-Key.  It is one way we provide complementary support to engineers, hobbyists, entrepreneurs, and other tech minded folks to assist you with your work. In many ways adding content to this website is the best part of our job, but it isn't our only job. We want to continue to develop and expand the eewiki, and you can help us justify our efforts by letting us know if you have used any of our content to help you use or select Digi-Key products.  Additionally, we welcome comments, feedback, suggestions, and questions.  Just send an email to  To address any questions or comments to a specific author, mention the author in the subject line.

Also, if the product you are designing meets certain criteria, we may be able to send you engineering samples.



  • No labels