Arduino and lcd oled I2C display

OLED I2C display have a 4 pins: GRD, VCC, SCL, SDA. These pins connect to Arduino in the following way:

OLED I2C Arduino Uno Arduino Nano Arduino Mega
GND GND GND GND
VСС 5V 5V 5V
SDA A4 A4 20
SCL A5 A5 21

Here is a simple program that outputs "Hello World" with help Adafruit_GFX library:

// connect Ardaful library
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
/*------------------------------------------------*/
#define OLED_RESET 7
Adafruit_SSD1306 display(OLED_RESET); // create object "display"
/*------------------------------------------------*/
void setup() {
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // display initialization via I2C interface, address 0x3C
  display.clearDisplay(); // clean display
  display.setTextSize(1); // setting font size
  display.setTextColor(WHITE); // setting text color
  display.setCursor(18, 12); // setting cursor to position X = 18; Y = 12
  display.print ("Hello, world!"); // write our phrase to the display buffer
  display.display(); // displaying
}


void loop() {
}

Post your comment

Search
Popular Posts
Subscribe
{{post}}