OLED 128X64 Connections

Hello, I am a newbie and purchased a unit from Ebay with 4 pins (which I can find wiring for) but the vendor sent me one with 6 pins as below and now I am lost! Pins are VCC Gnd CLK MOSI CS D/C
This is the description (albiet the wrong part)

Details about Blue 0.96" IIC/I2C Serial 128x64 OLED LCD LED Display Module Fr Arduino/STM32/51

Can anyone send a link to a successful hookup, etc? Thanks Jeff P.S. I understand about the library for oog

CLK MOSI CS and D/C is a classical SPI 4-wire interface. You could use u8glib for Arduino. However, D/C is call A0 in the u8glib documentation. Have a look at the gallery page. Such a OLED is listed there.

Oliver

Oliver--Thanks for your reply. I did see that picture but not how the pins connect to Arduino and get allocated in the sketch. I will look further in the documentation there. What do you mean by "call A0"? You mean analog out? I am pretty new to Arduino and programming so go easy...

Hi

"call A0": A typing error. I wanted to write "called A0". I mean, in u8glib, the pin D/C is named as A0. In fact the datasheets for the OLEDs and LCDs differ a lot with respect to the name of this pin.
With u8glib you can connect the four lines to the displays to any pin I/O of the Arduino, but you need to tell u8glib which pins you actually have used.

Oliver

Making some sense to me now. I have hooked up pins like this to my ardino mega according to the SSD1306 in the constructor using "Hello World":

SCK=13, MOSI=11,CS8,AO=9
I removed the comment from // to // on my SSD1306 selection.
Upon compiling I get tons of errors. So I looked at some other sketches and see they do like this
#define SCK 13 and so on for four lines...

Anyway, that did not compile either.

Any help/pointers at this stage?

You did use u8glib? Can you post code and a picture of your setup?

Oliver

Ok, I got two versions of code to compile but nothing appears on the OLED display!

#include "U8glib.h"

U8GLIB_SSD1306_128X64 u8g(13, 11, 8, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9


void draw(void) {
  // graphic commands to redraw the complete screen should be placed here  
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr( 0, 22, "Hello World!");
}

void setup(void) {
  // flip screen, if required
  // u8g.setRot180();
  
  // set SPI backup if required
  //u8g.setHardwareBackup(u8g_backup_avr_spi);

  // assign default color value
  if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
    u8g.setColorIndex(255);     // white
  }
  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
    u8g.setColorIndex(3);         // max intensity
  }
  else if ( u8g.getMode() == U8G_MODE_BW ) {
    u8g.setColorIndex(1);         // pixel on
  }
  else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
    u8g.setHiColorByRGB(255,255,255);
  }
}

void loop(void) {
  // picture loop
  u8g.firstPage();  
  do {
    draw();
  } while( u8g.nextPage() );
  
  // rebuild the picture after some delay
  delay(50);
}

and another compiled with no results at runtime:

[code]



#include "U8glib.h"

U8GLIB_SSD1306_128X64 u8g(13, 11, 8, 9); // SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9

void setup(void) {
  // assign default color value
  if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
    u8g.setColorIndex(255);     // white
  }
  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
    u8g.setColorIndex(3);         // max intensity
  }
  else if ( u8g.getMode() == U8G_MODE_BW ) {
    u8g.setColorIndex(1);         // pixel on
  }
  else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
    u8g.setHiColorByRGB(255,255,255);
  }
  
  u8g.setFont(u8g_font_fub30);
  //u8g.setFont(u8g_font_profont11);
  //u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr( 0, 32, "u8g library");
}

void loop(void) {
  static unsigned long thisMicros = 0;
  static unsigned long lastMicros = 0;
  
  // picture loop
  u8g.firstPage();  
  do {
    u8g.setPrintPos( 0, 36);
    u8g.print(thisMicros - lastMicros);
//    u8g.drawStr( 0, 60, "u8g library");
  } while( u8g.nextPage() );
  
  lastMicros = thisMicros;
  thisMicros = micros();
}

[/code]

Yes I used U8GLIB as you see in code

#include "U8glib.h"

U8GLIB_SSD1306_128X64 u8g(10, 11, 8, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9


void draw(void) {
  // graphic commands to redraw the complete screen should be placed here  
  u8g.setFont(u8g_font_unifont);
  //u8g.setFont(u8g_font_osb21);
  u8g.drawStr( 0, 12, "Hello You World!");
}

void setup(void) {
  // flip screen, if required
  // u8g.setRot180();
  
  // set SPI backup if required
  //u8g.setHardwareBackup(u8g_backup_avr_spi);

  // assign default color value
  if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
    u8g.setColorIndex(255);     // white
  }
  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
    u8g.setColorIndex(3);         // max intensity
  }
  else if ( u8g.getMode() == U8G_MODE_BW ) {
    u8g.setColorIndex(1);         // pixel on
  }
  else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
    u8g.setHiColorByRGB(255,255,255);
  }
}

void loop(void) {
  // picture loop
  u8g.firstPage();  
  do {
    draw();
  } while( u8g.nextPage() );
  
  // rebuild the picture after some delay
  delay(50);
}

Ok, I got it to work but it is flaky at best. Maybe my breadboard is corroded or wires are funky. Maybe the OLED is flaky. Sometimes the display won't return after a reset or is flickery. I have another on order so I will see. Thanks for the help. I included the working sketch...Jeff

P.S. This board worked at both 5 and 3.3v...

Nice to see that it works. Thanks for the pictures.

Oliver