//SSD1306 OLED DISPLAY
//LIBRARY FUNCTION USED :1)Adafruit SSD1306 2)Adafruit GFX Library
#include<Wire.h>
#include<Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// OLED display width and height
#define SCREEN_WIDTH 128 //Display Width And Height Is Fixed
#define SCREEN_HEIGHT 64
// Create display object (I2C address 0x3C is common)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup() {
// Initialize serial and OLED
Serial.begin(9600);//freq baud rate
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Check your OLED I2C address
Serial.println(F("SSD1306 allocation failed"));
for (;;); // Infinite loop on error
}
delay(2000); // Wait for display
// Clear the display
display.clearDisplay();
// Set text size and color
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.println("HELLO !!!");
display.display();
delay(2000);
// Display a new message
display.clearDisplay();
display.setTextSize(1);
display.setCursor(0, 0);
display.println("Welcome To OLED");
display.println("Arduino UNO");
display.display();
}
void loop() {
// put your main code here, to run repeatedly:
}
// OLED DISPLAY PIN CONFIGURATION
//GND - GROUND PIN (ANY)
//VCC PIN - ONLY 3.3V [FIXED]
//SDA - IN A4 PIN [FIXED] (SERIAL DATA LINE)
//SCL - IN A5 PIN [FIXED] (SERIAL CLOCK LINE)