Arm Mbed OS support forum

Displaying Text on a SSD1306 Oled display

Hello,
I am trying to get a small SSD1306 oled display working for a project on my school where we are building a warehouse robot. It is for my college education which i started half a year ago, that’s why i’m not a pro in software yet. I want to display something like “Afstand = %d” with the %d being a int which we need to preset before we press the start button from the robot. is there someone who can help me with the following things were i struggle with:
1: Which library do i need to import to Mbed, and do i have to edit something in these libraries so it works for my display.
2: how do send data to the SSD1306 so it will display the text?

i am using the following display:
Knipsel.PNG
and i am using the following Pinout on my F303K8
GND → Gnd
VCC → 3.3V
SCL → D5
SDA → D4

if someone could help me with a small simple code wich displays something will help me alot to understand how these displays work. i have tried the whole day and haven’t got any light of the display which is very frustating. i would be very thankfull.

I found this thread here which suggests this library.

To get something on the display, do i need to edit something in the library it self? and where do i need to say which pins i am using. im am using the online compiler and i am used to have all the pins i use sorted in the top. for example
#include “mbed.h”

DigitalIn button(D4);

i am also getting a error when compiling:
Error: #error directive: “Unknown target type” in “USBDevice/USBDevice/USBEndpoints.h”, Line: 55, Col: 3

Looking at the example code on the library page, you would need to specify the pins in the declaration of the display object:

I2CPreInit gI2C(p9,p10);
Adafruit_SSD1306_I2c gOled2(gI2C,p27);

It looks like the driver also wants a reset pin (p27 in the example code). You can probably just set that to any unused IO pin on your processor since it looks like that display has an automatic reset.