Controlling OLED display with Nano

Hi,
I have a project (using Arduino Nano) that only needs to display some alphanumeric texts, like "duty cycle: 80%". Originally I used a 16 X 2 LCD as that's the display I'm most familiar with but now I've realized that display is too large physically. I'm now interested in a small OLED like this:

It's the 4 pin version (Vcc, GND, SCL, SDA). Can any digital pin connect to SCL and SDA? The spec sheet mentions 3.3V - 5V for Vcc. I wonder if I can use the 5V from the Arduino for it?

The search I've found uses libraries like U8g2lib.h or Adafruit_SSD1351.h and I'm really confused on what they are and which one I should use.

Can someone write a simple sketch that just displays 2 short strings on 2 separate lines, please?

Thanks

SCL and SDA are usually A5 and A4 (CLOCK = 5 letters = A5 , DATA = 4 letters = A4)

We use English here. Your East Asien language is not useful here.

Thanks, that's very helpful.
I couldn't figure out where in the source code (the Adafruit version) it specifies that SCL and SDA are A5 and A4. Is it this line:

display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

No, that looks like a display sub-type and I2C address, overides for default kind and address.

SCL and SDA are lower down in Wire or whatever is actually being used to do the I2C stuff.

On the UNO, those signals are done by hardware, when you use the build in I2C those will always be the pins, A4 (look at all those As) DATA and A5 (five letters (hadn't seen that one)) CLOCK.

I2C pins are called out on any decent depiction of a particular Arduino board's pinout.

HTH

a7

I have looked in (I do not know if these are official files, but they seemed to be)

  • Wire.h - which receives sda and scl as local function arguments but does not define sda or scl
  • Arduino.h - where lots of #define happen, but no sda or scl - which seem to be passed into functions (from the sketch?)
  • TWI.h - which receives sda and scl as local function arguments
  • The datasheet - which describes sda and scl fifty times each, the pins on the ATMEGA328 (not the board), and their function.

Doesn't the 3V3 pin on the Uno/Nano outputs 3.3V? Wouldn't it be better to power the OLED from the 3V3 pin rather than 5V as shown in the tutorial since it mentions "Actually, all OLED displays run on 3.3V and power to the board as well as input signals are converted to 3.3V by an on-board voltage converter."

I do not see a difference in supply voltage if it matches the OLED, but lower volts means higher amps. I think the Arduino have a sourcing limit measured in mA.

Each Arduino board has its own SCL and SDA pins. Figure out which are used for your board.

If your curiosity is abject, they are defined in oins_arduino.h, about which you probably do not need to worry. I've never looked at it after all this time.

a7

This diagram may be useful for you. Image source

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.