Introduction: 0.96 OLED Display With Arduino & Getting Text From Serial Monitor...

Now we start to work with 0.96' OLED Display with arduino and we will try to display text from the serial monitor input...

Step 1: Connection With Arduino

In this tutorial i will show you how to connect and test and write some data from serial monitor to a 0.96" i2c OLED display module to an arduino.

Parts:

Breadboard and hookup wires Arduino The OLED i2c display

The connections from the display:

VCC to arduino 5v GND to arduino GND SCL to arduino pin A5 SDA to arduino pin A4

Both libraries below needs to be installed before you are able to continue with this instructable.

https://github.com/adafruit/Adafruit_SSD1306 (SSD1306 library)

https://github.com/adafruit/Adafruit-GFX-Library (GFX library)

Step 2: Correction in Library N Code..

For Adafruit_SSD1306 Library:

Go to: C:\Program Files (x86)\Arduino\libraries\Adafruit_SSD1306 Open Adafruit_SSD1306.h (in a text editor like Notepad++ for example)

Find and comment out the line: #define SSD1306_128_32 Uncomment the line: #define SSD1306_128_64

Open the ssd1306_128x64_i2c example in Arduino:

Change address from 0x3D to 0x3C in void setup()

Step 3: Uploading Testing Sketch

From examples go to adafruit SSD1306 upload the 3rd sketch.

Step 4: Getting Text From Serial Monitor to OLED Display...

Here is my code :

#include <SPI.h>
#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>

#define OLED_RESET 4

Adafruit_SSD1306 display(OLED_RESET);

#define NUMFLAKES 10

#define XPOS 0

#define YPOS 1

#define DELTAY 2

#define LOGO16_GLCD_HEIGHT 16

#define LOGO16_GLCD_WIDTH 16

static const unsigned char PROGMEM logo16_glcd_bmp[] = { B00000000, B11000000, B00000001, B11000000, B00000001, B11000000, B00000011, B11100000, B11110011, B11100000, B11111110, B11111000, B01111110, B11111111, B00110011, B10011111, B00011111, B11111100, B00001101, B01110000, B00011011, B10100000, B00111111, B11100000, B00111111, B11110000, B01111100, B11110000, B01110000, B01110000, B00000000, B00110000 };

#if (SSD1306_LCDHEIGHT != 64)

#error("Height incorrect, please fix Adafruit_SSD1306.h!");

#endif

void setup() {

Serial.begin(9600);

display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64) // init done // Show image buffer on the display hardware.

display.display(); //delay(2000);

display.setTextSize(1);

display.setTextColor(WHITE);

display.setCursor(10, 0);

display.clearDisplay();

display.println("INPUT YOUR TEXT HERE: ");

// invert the display

display.invertDisplay(true);

display.invertDisplay(false);

display.display();

display.clearDisplay(); }

void loop() {

while (1) {

display.setTextSize(1);

display.setTextColor(WHITE);

display.setCursor(10, 0);

display.clearDisplay();

display.println("input:");

printText();

display.display();

}

}

void printText(void) {

String s;

if (Serial.available()) {

s = Serial.readString(); //getting string input in variable "s"

display.println(s);

display.display();

display.println("\n");

}

delay(4000);

}

Comments

About This Instructable

242views

13favorites

License:

Bio: Currently am studying in CSE...interested in A.I. and robotics...
More by SiamH:4X4 Keypad Input Display Through OLEDUsing Minim OSD in NAZA0.96 OLED Display With Arduino & Getting Text From Serial Monitor...
Add instructable to: