Dmz the Lcd Display Is in Operation Use Power Button to Turn Lcd Display Off and Try Again

Bored of using LCD display in you Arduino projects once again and again? Well! They are indeed a thing of past. Enter the super-absurd OLED (Organic Light-Emitting Diode) displays! They're super-light, almost paper-thin, theoretically flexible, and produce a brighter and crisper picture.

SSD1306 OLED Commuter & its interfaces

At the heart of the module is a powerful single-scrap CMOS OLED driver controller – SSD1306. It tin communicate with the microcontroller in multiple ways including I2C and SPI.

SPI is mostly faster than I2C only requires more I/O pins. While I2C requires only two pins and can be shared with other I2C peripherals. It'southward a merchandise-off betwixt pins and speed. And so, it really boils down to your selection.

Thanks to the SSD1306 controller'southward versatility, the module comes in dissimilar sizes and colors: for example128x64, 128×32, with white OLEDs, Blue OLEDs and Dual Colour OLEDs. The skilful news is that all of these displays are swappable.

Ability Supply Requirement

An OLED brandish works without a backlight because it makes its own lite. This is why the display has such loftier contrast, extremely wide viewing angle and tin can display deep blackness levels. Absence of backlight significantly reduces the power required to run the OLED. On average the display uses almost 20mA current, although it depends on how much of the display is lit.

The operating voltage of the SSD1306 controller is from 1.65V to three.3V while OLED panel requires 7V to 15V supply voltage. All these different power requirements are sufficed using internal charge pump circuitry. This makes it possible to connect it to an Arduino or any 5V logic microcontroller hands without using whatsoever logic level converter.

OLED Memory Map

Regardless of the size of the OLED module, the SSD1306 driver has a congenital-in 1KB Graphic Brandish Information RAM (GDDRAM) for the screen which holds the flake pattern to be displayed. This 1K memory area is organized in eight pages (from 0 to seven). Each folio contains 128 columns/segments (block 0 to 127). And each column can store 8 bits of data (from 0 to 7). That surely tells united states of america we have

8 pages 10 128 segments x 8 bits of data = 8192 bits = 1024 bytes = 1KB memory

The whole 1K memory with pages, segments and data is highlighted below.

1KB 128x64 OLED Display RAM Memory Map

Each bit represents particular OLED pixel on the screen which tin can be turned ON or OFF programmatically.

The 128×64 OLED screen displays all the contents of RAM whereas 128×32 OLED screen displays only 4 pages (half content) of RAM.

Hither are the complete specifications:

OLED Brandish Module Pinout

Before diving into hookup and case code, allow'southward first have a look at its Pinout.

128x64 I2C OLED Display Pinout

GND should be connected to the ground of Arduino

VCC is the power supply for the display which nosotros connect the 5 volts pin on the Arduino.

SCL is a serial clock pin for I2C interface.

SDA is a series data pin for I2C interface.

Wiring OLED display module to Arduino Uno

Earlier nosotros get to uploading code and sending data to the display, let's claw the brandish upward to the Arduino.

Connections are fairly simple. Start by connecting VCC pin to the 5V output on the Arduino and connect GND to footing.

Now nosotros are remaining with the pins that are used for I2C communication. Note that each Arduino Board has unlike I2C pins which should be connected accordingly. On the Arduino boards with the R3 layout, the SDA (data line) and SCL (clock line) are on the pivot headers close to the AREF pin. They are likewise known as A5 (SCL) and A4 (SDA).

If you lot have a Mega, the pins are different! You lot'll want to employ digital 21 (SCL) and 20 (SDA). Refer below tabular array for quick understanding.

The following diagram shows you how to wire everything.

Wiring Fritzing Connecting 128x64 OLED Display Module With Arduino
Wiring 128×64 OLED Brandish Module With Arduino UNO

Installing Library for OLED Display Module

The SSD1306 controller of the OLED display has flexible yet complex drivers. Vast knowledge on retention addressing is required in social club to use the SSD1306 controller. Fortunately, Adafruit's SSD1306 library was written to hibernate away the complexities of the SSD1306 controller so that we can issue simple commands to control the display.

To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries alphabetize and update list of installed libraries.

Arduino Library Installation - Selecting Manage Libraries in Arduino IDE

Filter your search by typing 'adafruit ssd1306'. There should exist a couple entries. Await for Adafruit SSD1306 past Adafruit. Click on that entry, and then select Install.

Installing Adafruit SSD1306 Monochrome OLED Display Library

This Adafruit SSD1306 library is a hardware-specific library which handles lower-level functions. It needs to exist paired with Adafruit GFX Library to brandish graphics primitives like points, lines, circles, rectangles etc. Install this library as well.

Installing Adafruit GFX Graphics Core Library

Known Problem with SSD1306 Controller

Although the SSD1306 has a built-in GDDRAM for the screen, we cannot read the contents of it (co-ordinate to Adafruit). Therefore, it is not possible to manipulate the screen buffer to perform mathematical operations.

As an alternative, the library allocates 1KB (128×64)/8 bits) of memory from ATmega328P as buffer. So, it tin can manipulate the screen buffer and then perform a bulk transfer from the ATmega328P's memory to the internal memory of the SSD1306 controller.

Modifying Adafruit SSD1306 Library

Adafruit's SSD1306 Library isn't set for the 128×64 OLED displays (the one we are using correct at present). The display size must be changed in the Adafruit_SSD1306.h header file to go far work for united states. If it is not changed, an error message saying #error ("Height wrong, delight fix Adafruit_SSD1306.h!"); may appear when attempting to verify the example sketch in the Arduino IDE:

Height incorrect, please fix Adafruit_SSD1306.h Error

In order to change the Adafruit_SSD1306.h header file, open your sketchbook location. It'south generally My Documents > Arduino. Now go to libraries > Adafruit_SSD1306

Adafruit SSD1306 Library Location

Open Adafruit_SSD1306.h file in a text editor. Scroll downward the file to discover the section with the SSD1306 Displays or directly go to line no. 73. Comment out #define SSD1306_128_32 and uncomment #ascertain SSD1306_128_64 so that the lawmaking in this section looks similar this:

Remove Height Incorrect Error By Changing Adafruit_SSD1306.h File

That'south it. Now relieve the file and restart your Arduino IDE.

Arduino Code – Displaying Text

Now comes the interesting stuff!

The following examination sketch volition print 'Hello World!' message on the brandish. It also includes

  • Displaying Inverted text
  • Displaying Numbers
  • Displaying Numbers with base (Hex, Dec)
  • Displaying ASCII symbols
  • Scrolling Text Horizontally & Vertically
  • Scrolling office of the display

This volition requite you lot consummate agreement near how to use the OLED brandish and can serve equally the basis for more practical experiments and projects. Endeavor the sketch out and then we volition dissect it in some detail.

When building the sketch, the IDE will display a low memory warning message. This is considering the library allocates 1KB of retentivity from ATmega328P as display buffer. Y'all can ignore it.

            #include              <SPI.h>              #include              <Wire.h>              #include              <Adafruit_GFX.h>              #include              <Adafruit_SSD1306.h>              Adafruit_SSD1306              display(-1);              void              setup()    {              // initialize with the I2C addr 0x3C              display.begin(SSD1306_SWITCHCAPVCC,              0x3C);              // Clear the buffer.              display.clearDisplay();              // Brandish Text              brandish.setTextSize(i); 	display.setTextColor(WHITE); 	display.setCursor(0,28); 	brandish.println("Hullo globe!"); 	display.display();              delay(2000); 	display.clearDisplay();              // Display Inverted Text              display.setTextColor(Blackness, WHITE);              // 'inverted' text              display.setCursor(0,28); 	display.println("Hello world!"); 	display.display();              delay(2000); 	brandish.clearDisplay();              // Changing Font Size              display.setTextColor(WHITE); 	display.setCursor(0,24); 	display.setTextSize(2); 	display.println("Hello!"); 	display.display();              filibuster(2000); 	display.clearDisplay();              // Display Numbers              display.setTextSize(ane); 	display.setCursor(0,28); 	display.println(123456789); 	display.display();              filibuster(2000); 	display.clearDisplay();              // Specifying Base For Numbers              display.setCursor(0,28); 	display.print("0x"); display.impress(0xFF, HEX);  	display.print("(HEX) = "); 	display.print(0xFF, Dec); 	brandish.println("(Dec)");  	display.brandish();              filibuster(2000); 	display.clearDisplay();              // Display ASCII Characters              display.setCursor(0,24); 	display.setTextSize(ii); 	display.write(3); 	display.display();              delay(2000); 	display.clearDisplay();              // Whorl total screen              display.setCursor(0,0); 	display.setTextSize(1); 	display.println("Full"); 	brandish.println("screen"); 	brandish.println("scrolling!"); 	display.display(); 	display.startscrollright(0x00,              0x07);              delay(2000); 	display.stopscroll();              delay(1000); 	display.startscrollleft(0x00,              0x07);              filibuster(2000); 	display.stopscroll();              delay(1000);     	brandish.startscrolldiagright(0x00,              0x07);              delay(2000); 	brandish.startscrolldiagleft(0x00,              0x07);              filibuster(2000); 	display.stopscroll(); 	brandish.clearDisplay();              // Coil part of the screen              display.setCursor(0,0); 	display.setTextSize(1); 	brandish.println("Scroll"); 	display.println("some office"); 	display.println("of the screen."); 	brandish.display(); 	display.startscrollright(0x00,              0x00); }              void              loop() {}          

The sketch starts by including iv libraries viz. SPI.h, Wire.h, Adafruit_GFX.h and Adafruit_SSD1306.h. Although SPI.h library is not required for I2C OLED displays, nosotros demand to add it for the sake of compiling our program.

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

Next, we need to create an object of Adafruit_SSD1306.h. The Adafruit_SSD1306 constructor accepts Arduino pin number to which reset pin of the display is continued. As the OLED brandish nosotros are using doesn't have a RESET pivot, we will send -ane to the constructor so that none of the Arduino pins is used as a reset for the display.

            Adafruit_SSD1306              display(-1);          

In setup office: we need to initialize the OLED object using begin() function. The part takes two parameters. First parameter SSD1306_SWITCHCAPVCC turns the internal charge pump circuitry ON while second parameter provides I2C address of the OLED display. I2C address of such OLED display module is generally 0x3C. Information technology's fixed and cannot be changed.

Next, we articulate the buffer before press our beginning message on the screen.

                          // initialize with the I2C addr 0x3C              display.brainstorm(SSD1306_SWITCHCAPVCC,              0x3C);              // Clear the buffer.              display.clearDisplay();          

Displaying simple Text (Hello World)

Displaying Text On OLED Dsiplay Module
                              // Brandish Text                display.clearDisplay(); display.setTextSize(1); brandish.setTextColor(WHITE); display.setCursor(0,28); display.println("How-do-you-do world!"); display.display();                delay(2000);            

For displaying text on the screen, we demand to set the font size. This can exist washed past calling setTextSize() and passing font size (starting from 1) as a parameter.

Next, we need to gear up the font color past calling function setTextColor() . Laissez passer parameter WHITE for the dark background and pass Blackness for bright groundwork. Now before printing the message nosotros need to set the cursor position by calling office setCursor(X,Y). Pixels on the screen are addressed by their horizontal (10) and vertical (Y) coordinates. The coordinate organization places the origin (0,0) at the top left corner, with positive Ten increasing to the right and positive Y increasing downward.

We tin use simple impress(" ") or println(" ") function to print the message on the screen just like we impress data on serial monitor. Think, println() will move the cursor to the new line.

In order for the library to perform extremely fast mathematical operations on the screen buffer (more than 100 frames per 2nd), calls to the print functions do not immediately transfer the contents of screen buffer to the SSD1306 controller. A brandish() command is required to instruct the library to perform the bulk transfer from the screen buffer in the ATmega328P to the internal memory of the SSD1306 controller. As soon as the memory is being transferred, the pixels corresponding to the screen buffer volition show up on the OLED display.

Displaying Inverted Text

Displaying Inverted Text On OLED Dsiplay Module
                              // Display Inverted Text                brandish.clearDisplay(); display.setTextColor(BLACK, WHITE);                // 'inverted' text                display.setCursor(0,28); brandish.println("Hello world!"); display.display();                delay(2000);            

For displaying inverted text, we will call setTextColor(FontColor,BackgroundColor) office again. If you are paying attending, you know we passed only 1 parameter to this function earlier, but at present nosotros are passing two parameters. This is possible because of something called function overloading. Function overloading is the power to create multiple functions of the same proper name but with unlike ready of parameters. Calls to an overloaded function will run a specific implementation of that function depending upon the parameters passed.

In our example passing setTextColor(Black, WHITE) will render black text on filled background.

Scaling Font Size

Changing Font Size On OLED Dsiplay Module
                              // Changing Font Size                display.clearDisplay(); display.setTextColor(WHITE); display.setCursor(0,24); brandish.setTextSize(2); display.println("Hello!"); display.brandish();                delay(2000);            

Earlier in this tutorial, we called setTextSize() function to fix font size and passed 1 every bit parameter. You can use this function to calibration the font by passing any non-negative integer.

Characters are rendered in the ratio of 7:10. Significant, passing font size 1 volition render the text at seven×10 pixels per character, passing 2 volition render the text at 14×20 pixels per character so on.

The Adafruit_GFX library is responsible for rendering font. By default the mono-spaced font is selected. However, more recent versions of the Adafruit GFX library offer the ability to use alternate fonts. Several alternate fonts come with the library, plus in that location's the ability to add new ones.

Displaying Numbers

Displaying Numbers On OLED Dsiplay Module
                              // Brandish Numbers                brandish.clearDisplay(); display.setTextSize(1); brandish.setCursor(0,28); display.println(123456789); display.brandish();                delay(2000);            

Numbers can exist displayed on the OLED display past just calling print() or println() function. An overloaded implementation of these functions accepts 32-bit unsigned int, so you lot tin only brandish numbers from 0 to iv,294,967,295.

Specifying Base of operations For Numbers

Displaying HEX, Decimal, OCT, Binary On OLED Dsiplay Module
                              // Specifying Base For Numbers                display.clearDisplay(); display.setCursor(0,28); brandish.print("0x"); brandish.print(0xFF, HEX);  brandish.print("(HEX) = "); display.print(0xFF, DEC); display.println("(December)");  display.brandish();                delay(2000);            

The print() & println() functions has optional second parameter that specifies the base of operations (format) to apply; permitted values are BIN (binary, or base ii), OCT (octal, or base of operations 8), December (decimal, or base 10), HEX (hexadecimal, or base of operations 16). For floating point numbers, this parameter specifies the number of decimal places to use. For example:

  • print(78, BIN) gives "1001110"
  • print(78, October) gives "116"
  • print(78, DEC) gives "78"
  • print(78, HEX) gives "4E"
  • println(1.23456, 0) gives "ane"
  • println(1.23456, two) gives "1.23"
  • println(1.23456, 4) gives "one.2346"

Displaying ASCII Symbols

Displaying ASCII Symbols On OLED Dsiplay Module
                              // Display ASCII Characters                display.clearDisplay(); display.setCursor(0,24); display.setTextSize(two); display.write(iii); brandish.display();                filibuster(2000);            

The print() & println() functions send data to the display equally homo-readable ASCII text while write() role sends binary data to the display. So, you can use this part to display ASCII symbols. In our example sending number 3 will display centre symbol.

Total Screen Scrolling

Full-Screen-Scrolling-On-OLED-Dsiplay-Module
                              // Curl full screen                display.clearDisplay(); display.setCursor(0,0); display.setTextSize(ane); brandish.println("Full"); display.println("screen"); display.println("scrolling!"); brandish.display(); display.startscrollright(0x00,                0x07);                delay(2000); display.stopscroll();                delay(one thousand); display.startscrollleft(0x00,                0x07);                delay(2000); display.stopscroll();                delay(yard);     display.startscrolldiagright(0x00,                0x07);                delay(2000); display.startscrolldiagleft(0x00,                0x07);                filibuster(2000); display.stopscroll();            

You can gyre the display horizontally by calling startscrollright() & startscrollleft() functions and diagonally by calling startscrolldiagright() & startscrolldiagleft(). All these functions have two parameters viz. start page and cease page. Refer to OLED Retentivity Map section for caption of the pages. Every bit there are eight pages in the display from 0 to 7, you can scroll unabridged screen past scrolling all the pages i.east. passing parameters 0x00 and 0x07.

To stop display from scrolling you can utilize stopscroll() office.

Scrolling Specific Function

Scrolling Part Of The Screen On OLED Dsiplay Module
                              // Whorl part of the screen                display.setCursor(0,0); display.setTextSize(1); display.println("Scroll"); display.println("some part"); display.println("of the screen."); display.display(); display.startscrollright(0x00,                0x00);            

Sometimes we don't desire to scroll entire display. You lot can practise that by passing proper start page and stop page information to scrolling functions. Refer to OLED Memory Map section for explanation of the pages. As there are viii pages in the brandish from 0 to seven, you lot can scroll some part of the screen by passing specific page numbers as parameters.

In our example, we passed both the parameters as 0x00. This will scroll only start page (first 8 rows) of the brandish.

Arduino Code – Basic Drawings

In this example, we're going to try some basic drawings. This sketch demonstrates many drawing functions, including rectangles, circular rectangles, circles and triangles. Try the sketch out and and so we will dissect information technology in some detail.

            #include              <SPI.h>              #include              <Wire.h>              #include              <Adafruit_GFX.h>              #include              <Adafruit_SSD1306.h>              Adafruit_SSD1306              display(-one);              void              setup()    {              // initialize with the I2C addr 0x3C              display.begin(SSD1306_SWITCHCAPVCC,              0x3C);              // Clear the buffer.              display.clearDisplay();  	brandish.setTextSize(1); 	display.setTextColor(WHITE); 	display.setCursor(0,0); 	brandish.println("Rectangle"); 	display.drawRect(0,              15,              60,              40, WHITE); 	display.display();              filibuster(2000); 	brandish.clearDisplay();  	display.setTextSize(1); 	display.setTextColor(WHITE); 	display.setCursor(0,0); 	display.println("Filled Rectangle"); 	brandish.fillRect(0,              xv,              lx,              40, WHITE); 	display.brandish();              delay(2000); 	display.clearDisplay();  	brandish.setTextSize(1); 	display.setTextColor(WHITE); 	display.setCursor(0,0); 	brandish.println("Round Rectangle"); 	display.drawRoundRect(0,              15,              60,              40,              8, WHITE); 	brandish.display();              delay(2000); 	display.clearDisplay();  	display.setTextSize(1); 	display.setTextColor(WHITE); 	display.setCursor(0,0); 	brandish.println("Filled Round Rectangl"); 	brandish.fillRoundRect(0,              15,              60,              xl,              8, WHITE); 	display.display();              delay(2000); 	brandish.clearDisplay();  	display.setTextSize(i); 	display.setTextColor(WHITE); 	brandish.setCursor(0,0); 	display.println("Circle"); 	display.drawCircle(xx,              35,              xx, WHITE); 	display.brandish();              filibuster(2000); 	display.clearDisplay();  	display.setTextSize(1); 	display.setTextColor(WHITE); 	brandish.setCursor(0,0); 	display.println("Filled Circle"); 	display.fillCircle(20,              35,              20, WHITE); 	display.display();              delay(2000); 	brandish.clearDisplay();  	display.setTextSize(one); 	brandish.setTextColor(WHITE); 	display.setCursor(0,0); 	brandish.println("Triangle"); 	brandish.drawTriangle(30,              xv,              0,              60,              60,              60, WHITE); 	brandish.display();              delay(2000); 	display.clearDisplay();  	display.setTextSize(1); 	display.setTextColor(WHITE); 	display.setCursor(0,0); 	brandish.println("Filled Triangle"); 	display.fillTriangle(30,              fifteen,              0,              lx,              lx,              sixty, WHITE); 	display.display();              delay(2000); 	display.clearDisplay(); }              void              loop() {}          

Near of the lawmaking (Including libraries and initializing brandish) is aforementioned as above code example, except post-obit code snippets to describe bones drawings.

Drawing Rectangle

            display.clearDisplay(); brandish.setTextSize(1); brandish.setTextColor(WHITE); brandish.setCursor(0,0); display.println("Rectangle"); display.drawRect(0,              fifteen,              60,              40, WHITE); display.brandish();              delay(2000);  display.clearDisplay();   display.setTextSize(1); display.setTextColor(WHITE); display.setCursor(0,0); display.println("Filled Rectangle"); display.fillRect(0,              15,              threescore,              40, WHITE); display.display();              delay(2000);          

You tin can depict rectangle on the display by using drawRect() function. The office takes v parameters viz. 10 coordinate, Y coordinate, Width, Top and color. Actually this function draws hollow rectangle with i pixel border. You lot can depict filled rectangle using fillRect() role.

Drawing Round Rectangle

            display.clearDisplay(); display.setTextSize(i); display.setTextColor(WHITE); display.setCursor(0,0); display.println("Round Rectangle"); brandish.drawRoundRect(0,              15,              sixty,              forty,              eight, WHITE); display.display();              filibuster(2000);  display.clearDisplay();   display.setTextSize(ane); display.setTextColor(WHITE); display.setCursor(0,0); brandish.println("Filled Round Rectangl"); brandish.fillRoundRect(0,              xv,              60,              40,              8, WHITE); display.display();              delay(2000);          

You can draw round rectangle on the brandish by using drawRoundRect() function. This function takes aforementioned parameters equally drawRect() office except 1 additional parameter – Radius of corner rounding. Actually this part draws hollow round rectangle with 1 pixel edge. Yous can draw filled round rectangle using fillRoundRect() office.

Drawing Circumvolve

            display.clearDisplay(); brandish.setTextSize(i); display.setTextColor(WHITE); brandish.setCursor(0,0); display.println("Circumvolve"); display.drawCircle(20,              35,              20, WHITE); display.display();              delay(2000);  display.clearDisplay(); display.setTextSize(i); display.setTextColor(WHITE); display.setCursor(0,0); display.println("Filled Circle"); display.fillCircle(20,              35,              20, WHITE); brandish.display();              delay(2000);          

You tin can depict circle on the brandish by using drawCircle() function. The function takes four parameters viz. X coordinate of center, Y coordinate of center, radius and color. This function draws hollow circumvolve with one pixel edge. You can draw filled circumvolve using fillCircle() function.

Drawing Triangle

            display.clearDisplay(); brandish.setTextSize(1); display.setTextColor(WHITE); display.setCursor(0,0); display.println("Triangle"); display.drawTriangle(30,              fifteen,              0,              60,              60,              60, WHITE); display.brandish();              delay(2000);  brandish.clearDisplay(); display.setTextSize(1); brandish.setTextColor(WHITE); display.setCursor(0,0); brandish.println("Filled Triangle"); display.fillTriangle(thirty,              15,              0,              60,              60,              sixty, WHITE); display.display();              delay(2000);          

Y'all tin can draw triangle on the brandish by using drawTriangle() function. The office takes 7 parameters viz. iii 10 & Y coordinates (x0, y0, x1, y1, x2 & y2) of vertices of triangle and color. (X0,y0) represents top vertex, (x1,y1) represents left vertex and (x2,y2) represents correct vertex.

This function draws hollow triangle with 1 pixel border. You can describe filled triangle using fillTriangle() part.

Arduino Code – Displaying Bitmap

This last case shows how to draw bitmap images to the OLED Display. This is useful for creating splash screens of company logos, making sprites or only creating fun graphics for displaying information. Copy the following code, paste it into the Arduino IDE and click upload.

            #include              <SPI.h>              #include              <Wire.h>              #include              <Adafruit_GFX.h>              #include              <Adafruit_SSD1306.h>              Adafruit_SSD1306              display(-i);              // Bitmap of MarilynMonroe Epitome              const              unsigned              char              MarilynMonroe [] PROGMEM = {              0xff,              0xff,              0xff,              0xff,              0xff,              0xf8,              0x1f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xc0,              0x1f,              0xff,              0xff,              0xf0,              0x41,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x80,              0x7f,              0xff,              0xff,              0xf8,              0x03,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xf9,              0xff,              0xff,              0xff,              0xe0,              0x07,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x87,              0xff,              0xff,              0xff,              0xf8,              0x03,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x07,              0xff,              0xff,              0xff,              0xf8,              0x01,              0xf1,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x9f,              0xff,              0xff,              0xff,              0xf8,              0x00,              0xf8,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xbf,              0xff,              0xff,              0xff,              0xfc,              0x02,              0x78,              0x7f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xfc,              0x3f,              0xff,              0xff,              0xfe,              0x03,              0x7c,              0x1f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xf0,              0x07,              0xff,              0xff,              0xfe,              0x01,              0xfe,              0x1f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xfd,              0xe0,              0x03,              0xff,              0xff,              0xfc,              0x00,              0xfe,              0x0f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xfe,              0x87,              0xe0,              0xff,              0xff,              0xfc,              0x00,              0x06,              0x07,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xfc,              0x1f,              0xf9,              0xff,              0xff,              0xfc,              0x00,              0x02,              0x07,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xf8,              0x1f,              0xff,              0xff,              0xff,              0xfc,              0x00,              0xc3,              0xc3,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xf0,              0x3f,              0xff,              0xff,              0xe0,              0x0c,              0x00,              0xe7,              0x81,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xf0,              0x0f,              0xff,              0xff,              0xe0,              0x02,              0x00,              0x02,              0x00,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xf0,              0x0f,              0xff,              0xff,              0xe0,              0x01,              0x00,              0x00,              0x00,              0x3f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x80,              0x00,              0x3f,              0xff,              0xff,              0xe0,              0x00,              0x00,              0x1e,              0x3f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xfc,              0x00,              0x00,              0x0f,              0xff,              0x3f,              0xf8,              0x00,              0x18,              0x7f,              0x1f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xf8,              0x01,              0x80,              0x03,              0xfc,              0x3f,              0xfc,              0x00,              0x70,              0xfe,              0x1f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xf0,              0x43,              0xff,              0xff,              0xf8,              0x7f,              0xf8,              0x00,              0x00,              0x7e,              0x1f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xe0,              0x07,              0xff,              0xff,              0xf0,              0xff,              0xfc,              0x00,              0x00,              0x7c,              0x3f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xe0,              0x0f,              0xff,              0xff,              0xf1,              0xef,              0xf8,              0x00,              0x01,              0xfc,              0x3f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xe4,              0xff,              0xff,              0xff,              0xf3,              0x80,              0xa0,              0x00,              0x07,              0xfc,              0xaf,              0xff,              0xff,              0xff,              0xff,              0xff,              0xec,              0x5f,              0xff,              0xff,              0xe7,              0xf0,              0x00,              0x00,              0x03,              0xfe,              0xdf,              0xff,              0xff,              0xff,              0xff,              0xff,              0xee,              0x7f,              0xff,              0xff,              0xc7,              0xf8,              0x00,              0x00,              0x03,              0xff,              0xdf,              0xff,              0xff,              0xff,              0xff,              0xff,              0xfe,              0x7f,              0xff,              0xf7,              0xc7,              0xff,              0x06,              0x00,              0x03,              0xff,              0xbf,              0xff,              0xff,              0xff,              0xff,              0xff,              0xfe,              0x5f,              0xff,              0xc7,              0x07,              0xff,              0x80,              0x00,              0x07,              0xdb,              0xbf,              0xff,              0xff,              0xff,              0xff,              0xff,              0xee,              0xff,              0xff,              0x80,              0x03,              0xff,              0xc0,              0x00,              0x03,              0xc3,              0x0f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xfe,              0xff,              0xff,              0x98,              0x03,              0xff,              0xf8,              0x00,              0x07,              0xe0,              0x0f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xef,              0xff,              0xff,              0xf8,              0x01,              0xff,              0xfc,              0x01,              0x07,              0xfc,              0x1f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xcf,              0xef,              0xff,              0xff,              0xe1,              0xff,              0xfc,              0x01,              0x07,              0xf8,              0x1f,              0xff,              0xff,              0xff,              0xff,              0xff,              0x9f,              0xff,              0xff,              0x7f,              0xf1,              0xff,              0xf8,              0x02,              0x07,              0x88,              0x3f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xcf,              0xef,              0xf8,              0x0f,              0xff,              0xff,              0xe0,              0x00,              0x07,              0x84,              0x3f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xe7,              0xef,              0xf0,              0x04,              0x7f,              0xff,              0xc0,              0x00,              0x07,              0x84,              0x7f,              0xff,              0xff,              0xff,              0xff,              0xff,              0x3f,              0xff,              0xe0,              0x00,              0x1f,              0xff,              0x80,              0x00,              0x06,              0x04,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x3f,              0x7f,              0xe1,              0xf0,              0x07,              0xff,              0x80,              0x00,              0x07,              0x06,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xc3,              0xfe,              0x03,              0xff,              0x00,              0x00,              0x03,              0x80,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xf2,              0x3f,              0xc6,              0x7f,              0x81,              0xce,              0x00,              0x00,              0x01,              0xc1,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xe0,              0x3f,              0xc0,              0x07,              0xc1,              0xfe,              0x00,              0x00,              0x0d,              0xc0,              0x7f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xe0,              0x3f,              0xc0,              0x01,              0xe0,              0xfc,              0x00,              0x00,              0x0f,              0xc0,              0x7f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xc0,              0x3f,              0xc0,              0x00,              0x50,              0xfc,              0x00,              0x00,              0x0e,              0xc0,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xc0,              0x3f,              0xc0,              0x00,              0x18,              0xf8,              0x00,              0x00,              0x0e,              0xc1,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xc0,              0x3f,              0xc0,              0x00,              0x00,              0xf8,              0x00,              0x00,              0x66,              0x81,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xc0,              0x1f,              0xc7,              0x80,              0x00,              0xf8,              0x00,              0x01,              0xe0,              0x00,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xc0,              0x1f,              0xc1,              0xe0,              0x01,              0xf8,              0x00,              0x03,              0xf0,              0x01,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x80,              0x1f,              0xc0,              0x3e,              0x03,              0xf0,              0x00,              0x00,              0xe0,              0x03,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x00,              0x1f,              0xe0,              0xe0,              0x03,              0xf2,              0x00,              0x00,              0xc0,              0x03,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x80,              0x1f,              0xf0,              0x00,              0x07,              0xe6,              0x00,              0x00,              0xc0,              0x03,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x80,              0x1f,              0xff,              0x00,              0x1f,              0xee,              0x00,              0x00,              0x80,              0x07,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xb8,              0x0f,              0xff,              0xf0,              0x3f,              0xdc,              0x00,              0x00,              0x00,              0x0f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xbc,              0x0f,              0xff,              0xff,              0xff,              0xdc,              0x00,              0x00,              0x00,              0x0f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x9e,              0x0f,              0xff,              0xff,              0xff,              0xf8,              0x00,              0x00,              0x00,              0x1f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x08,              0x0f,              0xff,              0xff,              0xff,              0x70,              0x00,              0x00,              0x00,              0x1f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x00,              0x0b,              0xff,              0xff,              0xfe,              0xe0,              0x00,              0x00,              0x00,              0x1f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x00,              0x0b,              0xff,              0xff,              0xf9,              0xc0,              0x00,              0x00,              0x00,              0x3f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x3c,              0x09,              0xff,              0xff,              0xf1,              0x80,              0x00,              0x00,              0x00,              0x7f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x1e,              0x08,              0x3f,              0xff,              0xc0,              0x00,              0x00,              0x00,              0x00,              0x7f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x1f,              0x08,              0x03,              0xff,              0x00,              0x00,              0x00,              0x00,              0x00,              0x7f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x00,              0x08,              0x00,              0x00,              0x00,              0x00,              0x00,              0x00,              0x00,              0x1f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x80,              0x1c,              0x00,              0x00,              0x00,              0x00,              0x00,              0x00,              0x00,              0x1f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xce,              0x1c,              0x00,              0x00,              0x00,              0x00,              0x00,              0x00,              0x00,              0x1f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xfe,              0x1c,              0x00,              0x00,              0x00,              0x00,              0x00,              0x00,              0x00,              0x3f,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0xff,              0x7e,              0x00,              0x00,              0x00,              0x00,              0x00,              0x00,              0x00,              0x7f,              0xff,              0xff,              0xff              };              void              setup()    {              // initialize with the I2C addr 0x3C              brandish.begin(SSD1306_SWITCHCAPVCC,              0x3C);              // Clear the buffer.              display.clearDisplay();              // Display bitmap              display.drawBitmap(0,              0,  MarilynMonroe,              128,              64, WHITE); 	display.display();              // Invert Brandish              //display.invertDisplay(1);              }              void              loop() {}          

This is how the output looks like.

Displaying Bitmap Image On OLED Dsiplay Module

To testify bitmap image on the OLED display we need to telephone call drawBitmap() office. Information technology takes half dozen parameters viz. Top left corner X coordinate, summit left corner Y coordinate, byte array of monochrome bitmap, width of bitmap in pixels, superlative of bitmap in pixels and Color.

In our example, the bitmap image is 128×64 in size. And then, X & Y coordinates are ready to 0 while width & height is set to 128 & 64.

                          // Display bitmap              brandish.drawBitmap(0,              0,  MarilynMonroe,              128,              64, WHITE); brandish.display();          

But, before we can call the drawBitmap() part, nosotros first need an image to depict. Call back, the screen resolution of the OLED display is 128×64 pixels, so images larger than that volition not display correctly. To get a correctly sized paradigm, you lot tin can employ your favorite drawing programs like Inkscape, Photoshop, Paint, etc., setting the canvas size to 128×64 pixels.

We took laughing Marilyn Monroe image as an example and converted into 128×64 pixels using Paint and saved as .bmp.

Once you take a bitmap, information technology'due south time to convert it into an array that the SSD1306 OLED controller tin can understand. This can be done using two ways: Online method using image2cpp and Offline method using LCD Assistant.

Online Bitmap Array Generator – image2cpp

There's an online application called image2cpp – http://javl.github.io/image2cpp/ which can catechumen your image into an array. Image2cpp is newer and much more powerful than LCD Assistant (later solution). Information technology will allow you to:

  • Convert multiple images simultaneously.
  • Scale your prototype file – Stretch/Calibration to fit/Original
  • Accommodate the Effulgence threshold betwixt black and white.
  • Re-heart the epitome vertically and / or horizontally.
  • Reverse image colors

This tool is and then powerful that it can work offline equally well. Simply save the folio to your PC and open it in your browser. Thanks to Jasper van Loenen for his splendid contribution.

To begin with, open image2cpp in your browser and select whatsoever image you want to brandish on OLED screen.

Select Image - image2cpp Bitmap to Data Array Online Conversion Tool

The dimensions of your prototype will populate in Canvas size option under Epitome settings. If you have selected bigger epitome than 128×64, change information technology to 128×64 and select proper Scaling option. You lot can view the output in Preview section.

Y'all can modify the Background color or Capsize image colors if necessary.

Finally, change the most important option – Effulgence threshold as per your requirement. Setting threshold will brand pixels above this level white and beneath black. In our case we have set it to 171 to get prissy details of Marilyn Monroe.

Image Settings - image2cpp Bitmap to Data Array Online Conversion Tool

This picayune preview reflects whatever changes you make in your settings. You tin change settings while keeping eye on it.

Image Preview - image2cpp Bitmap to Data Array Online Conversion Tool

Once yous are satisfied with the outcome, you can keep generating the data assortment. Simply select Code output format as Arduino Code and click on Generate code button.

Just for your information, there's an option called Depict mode. It actually creates image co-ordinate to the scanning patter of the brandish. If your paradigm looks all messed upwards on your display, attempt changing the mode.

Generating Output - image2cpp Bitmap to Data Array Online Conversion Tool

That's information technology. The byte array of your bitmap will be generated. Yous can use the output directly with our case code. But be sure to name it appropriately. Then call your assortment within the drawBitmap() office.

Arduino Code Output - image2cpp Bitmap to Data Array Online Conversion Tool

Offline Bitmap Array Generator – LCD Assistant

In that location's another application chosen LCD banana – http://en.radzio.dxp.pl/bitmap_converter/ which can convert your bitmap paradigm into data assortment. It's not as powerful as image2cpp but still pop among hobbyists.

To first with, you demand to convert yous image into 128×64 i-scrap monochrome bitmap. Y'all tin can apply your favorite drawing programs like Inkscape, Photoshop, Paint, etc. to practice it, just similar we did in MS paint.

Open your file in MS Paint and resize information technology to 128×64.

Opening Image in Paint

Now, save your file as bitmap. While saving the file cull Salvage as type : Monochrome Bitmap(*.bmp;*.dib). This will generate 1-bit/binary bitmap prototype that has but 2 possible values for each pixel i.e. 0 (black) or 1 (white).

Saving 1-bit Monochrome Bitmap Image in MS Paint

The only downside here is that y'all cannot set up brightness threshold level. It is gear up to fifty% by default and cannot exist changed.

Anyways now, download LCD assistant program. Open the executable and load your bitmap from File menu.

LCD Assistant Converts Bitmap Image to Data Array For LCD,OLED,Graphic Displays

There's nothing much you lot tin can do with this tool. So, merely become to File menu and click on Save output selection. Save the file as text file.

Just for your information, there'southward an selection called Byte Orientation. It actually creates prototype according to the scanning patter of the display. If your image looks all messed up on your brandish, try changing the mode.

Save Output Of LCD Assistant

That's it. With your array created, paste it into your code.

Bitmap to Data Array Conversion Output - LCD Assistant Application

Merely be sure to name information technology appropriately. So call your assortment inside the drawBitmap() function.

spearsgail1974.blogspot.com

Source: https://lastminuteengineers.com/oled-display-arduino-tutorial/

0 Response to "Dmz the Lcd Display Is in Operation Use Power Button to Turn Lcd Display Off and Try Again"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel