B4R Tutorial How to connect a 7 pin OLED display, (NOT 4 pin)...

Peter Simpson

Expert
Licensed User
Here is how to connect a 7 pin OLED display to an Arduino.

If you are anything like me, you previously owned a Raspberry Pi and did absolutely nothing with it. Well before I ever owned any Arduino hardware I had purchased this blue 128 x 64 OLED display. Today I decided to connect it to my Uno.

On the forum you will find that Erel demonstrates a 4 pin OLED display working perfect bouncing a ball around the display, that program will NOT work with this display without using ALL of the pins. If you use the below wiring legend and the below Initialization string with Erel's ball program, you will happily see a ball quickly bouncing around your 7 pin OLED display.

BTW before somebody contacts me to say that they removed the GND and VCC jumpers leads and the display still works, it's not recommended that you do that. The GND and VCC are their for a reason, so you should really use them.

You need the following libraries: rAdafruitGFX and rAdafruitSSD1306 under your libraries tab.

What it looks like when wired up.
IMG_20170305_163441.jpg


Labels: SCK also known as D0 & SDA also known as D1 on some OLED displays.
IMG_20170305_163028.jpg

B4X:
'WIRE LEGEND for 12864 7 pin OLED display
'VCC (VDD)= 3.3V
'GND = GND
'D0 (SCK) = D13
'D1 (SDA) = D11
'RST (RES) = D8
'DC = D9
'CS (SS) = D10

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public Serial1 As Serial
    Public SSD As AdafruitSSD1306
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")

    'I could have declared the pins in Globals and initialised them here, but I opted not to do that.

    SSD.InitializeHSPI(9, 8, 10) 'in Erels ball demo, use this InitializeHSPI instead to see the ball bounce
    SSD.ClearDisplay
    SSD.GFX.ConfigureText(1, SSD.WHITE, False)

    SSD.GFX.SetCursor(7, 0)
    SSD.GFX.DrawText("B4X +=1")

    SSD.GFX.SetCursor(7, 10)
    SSD.GFX.DrawText("That does not work")

    SSD.GFX.SetCursor(54, 25)
    SSD.GFX.DrawText(":-(")

    SSD.Display
End Sub
 
Last edited:
Top