Displaying Custom Images on 0.96-Inch OLED Display Using NODE MCU


Displaying custom images on 0.96-inch OLED display using NODE MCU

Programming a 16X2 LCD is simpler compared to other graphic displays. But when it comes to displaying an image in your display 16X2 LCD fails. In order to overcome this, we can use 0.96-inch OLED. SSD1306 display (128×64) is a monochrome display which means it has only one color (blue in this example). The display itself is having a chip (SSD1306) which can communicate with other master devices using I2C or SPI protocols.in this example we are communicating with our display using SPI protocol which is faster than I2C. Pins used are as follows: SCK, SDA, CS (chip select: active low), D/C (data/command) and a rest pin (RST).

PLC Course in Chennai

 

Adafruit Industries provides a library for the SSD1306 OLED, Install the  library for SSD1306 OLED using Arduino library manager (Sketch —> Include Library —> Library Manager), or manually by downloading the zip file for the library from the following link and adding it to Arduino libraries folder (C:\Program Files\Arduino\libraries):

https://github.com/adafruit/Adafruit_SSD1306

 

Generating a hex file matrix from an image

Open LCDAssistant software and load a binary image of resolution 128 X 64 pixels.

Load our image File => Load image

PLC Course in Chennai

Then save your output Fileà Save output

 

 

Connect  SSD1306 display to your Node MCU as follows

MOSI  D3

CLK   D4

DC    D1

CS    D0

RESET D2

GND GND

VDD 3V3

PLC Course in Chennai

Copy and paste the following code into Arduino ide

 

 

 

 

Program

#include <SPI.h>

#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>

 

#define OLED_MOSI  D3

#define OLED_CLK   D4

#define OLED_DC    D1

#define OLED_CS    D0

#define OLED_RESET D2

Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

 

#define NUMFLAKES 10

#define XPOS 0

#define YPOS 1

#define DELTAY 2

 

#define LOGO16_GLCD_HEIGHT 16

#define LOGO16_GLCD_WIDTH  16

 

 

const unsigned char PROGMEM bitmap[] =

{

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x0F, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x3F, 0x00, 0x40, 0x0F, 0xE0, 0x7F, 0xFF, 0xF0, 0x03, 0xFF, 0xFC, 0x02, 0x00, 0x02, 0x00,

0x00, 0x7C, 0x00, 0x00, 0x0F, 0xC0, 0x7F, 0xFF, 0xFC, 0x07, 0xFF, 0xFC, 0x1F, 0xFF, 0xFE, 0x00,

0x00, 0xF0, 0x00, 0x00, 0x0F, 0xC0, 0x7F, 0xFF, 0xFE, 0x0F, 0xFF, 0xFC, 0x1F, 0xFF, 0xFE, 0x00,

0x00, 0xE0, 0x08, 0x00, 0x0F, 0xC0, 0xFF, 0xFF, 0xFE, 0x0F, 0xFF, 0xFC, 0x1F, 0xFF, 0xFE, 0x00,

0x01, 0xC0, 0xFF, 0x80, 0x0F, 0xC1, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x04, 0x1F, 0xFF, 0xFE, 0x00,

0x01, 0x83, 0xC0, 0x20, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00,

0x03, 0x07, 0x00, 0x00, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00,

0x03, 0x0C, 0x00, 0x00, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00,

0x03, 0x0C, 0x0F, 0x80, 0x0F, 0xC0, 0x7F, 0xFF, 0xFE, 0x0F, 0xC0, 0x00, 0x1F, 0xFF, 0xF8, 0x00,

0x02, 0x10, 0x20, 0x00, 0x0F, 0xC0, 0x7F, 0xFF, 0xFE, 0x0F, 0xC0, 0x00, 0x1F, 0xFF, 0xFC, 0x00,

0x02, 0x10, 0x40, 0x00, 0x0F, 0xC0, 0x7F, 0xFF, 0xFC, 0x0F, 0xC0, 0x00, 0x1F, 0xFF, 0xFE, 0x00,

0x02, 0x10, 0x80, 0x00, 0x0F, 0xC0, 0x7F, 0xFF, 0xF8, 0x0F, 0xC0, 0x00, 0x0F, 0xFF, 0xFE, 0x00,

0x02, 0x01, 0x00, 0x00, 0x0F, 0xC0, 0x7F, 0x00, 0x00, 0x0F, 0xC0, 0x00, 0x00, 0x01, 0xFE, 0x00,

0x02, 0x20, 0x01, 0x80, 0x0F, 0xC0, 0x7F, 0x00, 0x00, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0xFE, 0x00,

0x00, 0x00, 0x07, 0xE0, 0x0F, 0xC0, 0x7F, 0x00, 0x00, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0xFE, 0x00,

0x00, 0x00, 0x0F, 0xF0, 0x0F, 0xC0, 0x7F, 0x00, 0x00, 0x0F, 0xC0, 0x00, 0x00, 0x01, 0xFE, 0x00,

0x00, 0x00, 0x0F, 0xF0, 0x0F, 0xC0, 0x7F, 0x00, 0x00, 0x0F, 0xFF, 0xFC, 0x1F, 0xFF, 0xFE, 0x00,

0x00, 0x00, 0x0F, 0xF0, 0x0F, 0xC0, 0x7F, 0x00, 0x00, 0x0F, 0xFF, 0xFC, 0x1F, 0xFF, 0xFE, 0x00,

0x00, 0x00, 0x0F, 0xF0, 0x0F, 0xC0, 0x7F, 0x00, 0x00, 0x07, 0xFF, 0xFC, 0x1F, 0xFF, 0xFE, 0x00,

0x00, 0x00, 0x07, 0xE0, 0x0F, 0xC0, 0x7F, 0x00, 0x00, 0x07, 0xFF, 0xFC, 0x1F, 0xFF, 0xFC, 0x00,

0x00, 0x00, 0x03, 0xC0, 0x0F, 0xE0, 0x7F, 0x00, 0x00, 0x01, 0xFF, 0xFC, 0x3F, 0xFF, 0xF8, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

};

 

 

#define SSD1306_LCDHEIGHT 64

#if (SSD1306_LCDHEIGHT != 64)

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

#endif

 

void setup()

{

display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

display.clearDisplay();

 

}

 

void loop()

{

 

display.drawBitmap(0,0,bitmap,256,256, WHITE);

display.display();

delay(800);

display.clearDisplay();

delay(50);

}

 

Verify and upload the code into your node MCU. If you wish to display custom images change the hex value matrix with the one obtained from LCDAssitant application.

Sample output is shown below.

PLC Course in Chennai

About IPCS Automation

IPCS- Ingenious Power and Control Systems P LTD is the leading Automation Course providers in India and also the outside part of India and also the trainees in this institution are the industry experts and they have the years of experience in the Automation industry.IPCS Automation providing PLC Course in Chennai. Our training session for all area of Automation is special we are involving the students in the live projects and also that way they become a pro in the industry and also our PLC Training is also in this same way are we following our PLC Training in Chennai is in the same manner and also the students can easily explore the jobs from Chennai.

 

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

Find Us

Address
123 Main Street
New York, NY 10001

Hours
Monday—Friday: 9:00AM–5:00PM
Saturday & Sunday: 11:00AM–3:00PM

About This Site

This may be a good place to introduce yourself and your site or include some credits.

Find Us

Address
123 Main Street
New York, NY 10001

Hours
Monday—Friday: 9:00AM–5:00PM
Saturday & Sunday: 11:00AM–3:00PM

About This Site

This may be a good place to introduce yourself and your site or include some credits.