Mbed LPC1768 with OLED

Hello,
I am using Mbed LPC1768 with 128x64 OLED. I am using the below code to display a character. It compiles but the OLED does not display the character, and I can see the embed led1 is blinking. Does anyone know why the below code doesn’t work?

#include “mbed.h”
#include “Adafruit_SSD1306.h”

I2C i2c_oled(p28, p27);
Adafruit_SSD1306_I2c oled(i2c_oled, NC, 0x7A, 64, 128);

int main()
{
while(1)
{
oled.clearDisplay();
oled.setTextSize(1);
oled.setTextColor(SSD1306_WHITE);
oled.setTextCursor(0, 0);
oled.writeChar(‘H’);
oled.display();
}
}

Hello,
At first I wish all a merry christmas!
To your question:
I think you should do all the display stuff outside the while(1) loop because
you are clearing the display all the time.
‘’'int main()
{
oled.clearDisplay();
oled.setTextSize(1);
oled.setTextColor(SSD1306_WHITE);
oled.setTextCursor(0, 0);
oled.writeChar(‘H’);
oled.display();
while(1)
{
}
}

BR, Walter

Hello Walter, thanks for your response. I was thinking I might choose the wrong adafruit library because when I compile the above code, it says that
class “Adafruit_SSD1306_I2c” has no member “setTextSize” “oled.setTextSize(1);”

This works perfectly for the Arduino but not in Mbed.

Finally its working!! with the below code.

#include “mbed.h”
#include “Adafruit_SSD1306.h”
#define SDA p28
#define SCL p27

class I2C2 : public I2C
{
public:
I2C2(PinName sda, PinName scl) : I2C(sda, scl) {
frequency(400000);
start();
};
};

I2C2 gI2C(SDA,SCL);
Adafruit_SSD1306_I2c oled(gI2C, NC, 0x78, 64, 128);

int main()
{
while (1)
{
oled.clearDisplay();
oled.setTextSize(1);
oled.setTextCursor(20, 40);
oled.printf(“Merry Christmas!”);
oled.display();
}
}