Newhaven Display Forum

Newhaven Products => OLEDs => Topic started by: llamero on February 14, 2018, 07:09:28 PM

Title: Arduino demo code for running the NHD-0420DZW-AB5 OLED display via SPI
Post by: llamero on February 14, 2018, 07:09:28 PM
I worked out a few functions that allow the NHD-0420DZW-AB5 OLED display to be controlled via SPI on an Arduino.  The catch is that the 2-bit RsRW header means that communication requires bitbanging rather than using the SPI library, since the SPI library can only send 8-bit blocks.

The demo code will initialize the display, load up a splash screen, and then show animated arrows.  The CS pin is pin 9, and all the other pins are the standard SPI pins.  One note, bitbanging is much slower than the built in SPI bus (2MHz vs 20MHz), so you can use SPI.end() and SPI.begin() to toggle the SPI bus off and on (the SPI bus has to be off to allow the bitbanging function to work, and on to allow the SPI library to work).

The code can be found at: https://github.com/Llamero/OLED_Display_Demo/blob/master/Minimal_display_code/Minimal_display_code.ino

If anyone has improvements, please feel free to create a fork.

Cheers,
  Ben Smith
Title: Re: Arduino demo code for running the NHD-0420DZW-AB5 OLED display via SPI
Post by: Ted_M on May 21, 2018, 11:28:30 AM
Thanks for submitting your example code!  This is very helpful.