{"id":706,"date":"2020-09-14T18:37:07","date_gmt":"2020-09-14T11:37:07","guid":{"rendered":"https:\/\/www.makeriot2020.com\/?p=706"},"modified":"2020-09-14T18:37:10","modified_gmt":"2020-09-14T11:37:10","slug":"the-oled-display","status":"publish","type":"post","link":"https:\/\/www.makeriot2020.com\/index.php\/2020\/09\/14\/the-oled-display\/","title":{"rendered":"The OLED Display"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p>Adding a display to any project can instantly increase its visual appeal, as well as make the project easier to control. Displays available to Electronic enthusiasts mostly include some sort of LCD or even TFT display. LCD displays are usually bulky and very limited in their ability to display a lot of information, whereas TFT type displays are still a bit on the expensive side, and not very easy to interface with for the beginner.<br><br>Today, I would like to introduce a different type of display, which is available in an I2C as well as SPI version. These displays are very easily readable in almost any light conditions, lightweight, and most importantly, they are extremely cheap. I am talking about the OLED display of course&#8230; Many of us may already have one of them in our mobile phones, or even TV screen&#8230;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"768\" height=\"1024\" data-src=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/20200914_175650-768x1024.jpg\" alt=\"\" class=\"wp-image-707 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_175650-768x1024.jpg 768w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_175650-scaled-600x800.jpg 600w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_175650-225x300.jpg 225w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_175650-1152x1536.jpg 1152w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_175650-1536x2048.jpg 1536w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_175650-scaled.jpg 1920w\" data-sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 768px; --smush-placeholder-aspect-ratio: 768\/1024;\" \/><figcaption>128&#215;32 I2C OLED Display (40mmx10mm) [0.91&#8243;] Front view<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Some Technical Data <\/h2>\n\n\n\n<p>An&nbsp;<strong>organic light-emitting diode<\/strong>&nbsp;(<strong>OLED<\/strong>&nbsp;or&nbsp;<strong>Organic LED<\/strong>), also known as an&nbsp;<strong>organic EL<\/strong>&nbsp;(organic electroluminescent) diode,<sup><a href=\"https:\/\/en.wikipedia.org\/wiki\/OLED#cite_note-1\">[1]<\/a><\/sup><sup><a href=\"https:\/\/en.wikipedia.org\/wiki\/OLED#cite_note-2\">[2]<\/a><\/sup>&nbsp;is a&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Light-emitting_diode\">light-emitting diode<\/a>&nbsp;(LED) in which the&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Emission_(electromagnetic_radiation)\">emissive<\/a>&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Electroluminescence\">electroluminescent<\/a>&nbsp;layer is a film of&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Organic_compound\">organic compound<\/a>&nbsp;that emits light in response to an electric current. This organic layer is situated between two electrodes; typically, at least one of these electrodes is transparent. OLEDs are used to create&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Digital_display\">digital displays<\/a>&nbsp;in devices such as&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Television_set\">television<\/a>&nbsp;screens,&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Computer_monitor\">computer monitors<\/a>, portable systems such as&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Smartphone\">smartphones<\/a>,&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Handheld_game_console\">handheld game consoles<\/a>&nbsp;and&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Personal_digital_assistant\">PDAs<\/a>. A major area of research is the development of white OLED devices for use in&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Solid-state_lighting\">solid-state lighting<\/a>&nbsp;applications.<sup><a href=\"https:\/\/en.wikipedia.org\/wiki\/OLED#cite_note-3\">[3]<\/a><\/sup><sup><a href=\"https:\/\/en.wikipedia.org\/wiki\/OLED#cite_note-4\">[4]<\/a><\/sup><sup><a href=\"https:\/\/en.wikipedia.org\/wiki\/OLED#cite_note-5\">[5]<\/a><\/sup><\/p>\n\n\n\n<p>There are two main families of OLED: those based on small molecules and those employing&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Polymer\">polymers<\/a>. Adding mobile&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Ion\">ions<\/a>&nbsp;to an OLED creates a&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Light-emitting_electrochemical_cell\">light-emitting electrochemical cell<\/a>&nbsp;(LEC) which has a slightly different mode of operation. An OLED display can be driven with a&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Passive_matrix_addressing\">passive-matrix<\/a>&nbsp;(PMOLED) or&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Active_matrix\">active-matrix<\/a>&nbsp;(<a href=\"https:\/\/en.wikipedia.org\/wiki\/AMOLED\">AMOLED<\/a>) control scheme. In the PMOLED scheme, each row (and line) in the display is controlled sequentially, one by one,<sup><a href=\"https:\/\/en.wikipedia.org\/wiki\/OLED#cite_note-6\">[6]<\/a><\/sup>&nbsp;whereas AMOLED control uses a&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Thin-film_transistor\">thin-film transistor<\/a>&nbsp;backplane to directly access and switch each individual pixel on or off, allowing for higher resolution and larger display sizes.<\/p>\n\n\n\n<p>An OLED display works without a\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Backlight\">backlight<\/a>\u00a0because it emits\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Visible_light\">visible light<\/a>. Thus, it can display deep\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Black_level\">black levels<\/a>\u00a0and can be thinner and lighter than a\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Liquid_crystal_display\">liquid crystal display<\/a>\u00a0(LCD). In low ambient light conditions (such as a dark room), an OLED screen can achieve a higher\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Contrast_ratio\">contrast ratio<\/a>\u00a0than an LCD, regardless of whether the LCD uses\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Cold_cathode\">cold cathode fluorescent lamps<\/a>\u00a0or an\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/LED-backlit_LCD_display\">LED backlight<\/a>. OLED displays are made in the same way as LCDs, but after TFT (for active matrix displays), addressable grid (for passive matrix displays) or ITO segment (for segment displays) formation, the display is coated with hole injection, transport and blocking layers, as well with electroluminescent material after the 2 first layers, after which ITO or metal may be applied again as a cathode and later the entire stack of materials is encapsulated. The TFT layer, addressable grid or ITO segments serve as or are connected to the anode, which may be made of ITO or metal.<sup><a href=\"https:\/\/en.wikipedia.org\/wiki\/OLED#cite_note-7\">[7]<\/a><a href=\"https:\/\/en.wikipedia.org\/wiki\/OLED#cite_note-8\">[8]<\/a><\/sup>\u00a0OLEDs can be made flexible and transparent, with\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Transparent_display\">transparent displays<\/a>\u00a0being used in smartphones with optical fingerprint scanners and\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Flexible_display\">flexible displays<\/a>\u00a0being used in foldable smartphones.<\/p>\n\n\n\n<p>The full article is available <a rel=\"noreferrer noopener\" href=\"https:\/\/en.wikipedia.org\/wiki\/OLED#Working_principle\" target=\"_blank\">here<\/a> if you are interested.<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"768\" height=\"1024\" data-src=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/20200914_175719-768x1024.jpg\" alt=\"\" class=\"wp-image-708 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_175719-768x1024.jpg 768w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_175719-scaled-600x800.jpg 600w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_175719-225x300.jpg 225w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_175719-1152x1536.jpg 1152w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_175719-1536x2048.jpg 1536w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_175719-scaled.jpg 1920w\" data-sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 768px; --smush-placeholder-aspect-ratio: 768\/1024;\" \/><figcaption>128&#215;32 I2C OLED Display (40mmx10mm) [0.91&#8243;] Back view<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Connecting the circuit<\/h2>\n\n\n\n<p>This display is once again extremely easy to connect, as it uses the very versatile I2C protocol. (An SPI version is also available). <br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"768\" height=\"1024\" data-src=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/20200914_181046-768x1024.jpg\" alt=\"\" class=\"wp-image-711 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_181046-768x1024.jpg 768w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_181046-scaled-600x800.jpg 600w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_181046-225x300.jpg 225w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_181046-1152x1536.jpg 1152w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_181046-1536x2048.jpg 1536w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_181046-scaled.jpg 1920w\" data-sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 768px; --smush-placeholder-aspect-ratio: 768\/1024;\" \/><figcaption>Connecting 128&#215;32 OLED display to an Arduino Uno Clone<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-gallery columns-2 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\"><ul class=\"blocks-gallery-grid\"><li class=\"blocks-gallery-item\"><figure><img decoding=\"async\" width=\"768\" height=\"1024\" data-src=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/20200914_181118-768x1024.jpg\" alt=\"\" data-id=\"712\" data-full-url=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/20200914_181118-scaled.jpg\" data-link=\"http:\/\/144.126.248.244\/?attachment_id=712\" class=\"wp-image-712 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_181118-768x1024.jpg 768w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_181118-scaled-600x800.jpg 600w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_181118-225x300.jpg 225w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_181118-1152x1536.jpg 1152w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_181118-1536x2048.jpg 1536w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_181118-scaled.jpg 1920w\" data-sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 768px; --smush-placeholder-aspect-ratio: 768\/1024;\" \/><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><img decoding=\"async\" width=\"1024\" height=\"768\" data-src=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/20200914_181144-1024x768.jpg\" alt=\"\" data-id=\"713\" data-full-url=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/20200914_181144-scaled.jpg\" data-link=\"http:\/\/144.126.248.244\/?attachment_id=713\" class=\"wp-image-713 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_181144-1024x768.jpg 1024w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_181144-scaled-600x450.jpg 600w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_181144-300x225.jpg 300w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_181144-768x576.jpg 768w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_181144-1536x1152.jpg 1536w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200914_181144-2048x1536.jpg 2048w\" data-sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/768;\" \/><\/figure><\/li><\/ul><figcaption class=\"blocks-gallery-caption\">A Closeup view of the wiring. Red = +5v, Blue = GND (0v), Orange = SDA, Brown = SCL<\/figcaption><\/figure>\n\n\n\n<p>Connect the following wires to the Arduino \/ ESP32<br>+5v (red) to the VCC pin on the display<br>Gnd to Gnd<br>SDA (A4 on Uno) to SDA, and SCL (A5 on Uno) to SCL<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Software Libraries<\/h2>\n\n\n\n<p>The 128&#215;32 OLED display that we will be using today, is based on the SSD1306. We will thus be using a library suplied by Adafruit to interface with this chip. There are various other libraries available, but I have found the Adafruit library the most stable.<br><br>To load this, start by opening the Arduino IDE, and go to the Sketch->Include Library->Manage Libraries option on the menu<\/p>\n\n\n\n<p>The Library Manager will now open<br><\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"862\" height=\"486\" data-src=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/Screenshot-at-2020-09-14-18-23-59.png\" alt=\"\" class=\"wp-image-714 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Screenshot-at-2020-09-14-18-23-59.png 862w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Screenshot-at-2020-09-14-18-23-59-600x338.png 600w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Screenshot-at-2020-09-14-18-23-59-300x169.png 300w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Screenshot-at-2020-09-14-18-23-59-768x433.png 768w\" data-sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 862px; --smush-placeholder-aspect-ratio: 862\/486;\" \/><\/figure>\n\n\n\n<p>We need to install two (2) Libraries<br><br>&#8211; Adafruit GFX ( this is for graphics)<br>&#8211; Adafruit SSD1306 ( to control the actual display )<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"860\" height=\"485\" data-src=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/Screenshot-at-2020-09-14-18-24-48.png\" alt=\"\" class=\"wp-image-715 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Screenshot-at-2020-09-14-18-24-48.png 860w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Screenshot-at-2020-09-14-18-24-48-600x338.png 600w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Screenshot-at-2020-09-14-18-24-48-300x169.png 300w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Screenshot-at-2020-09-14-18-24-48-768x433.png 768w\" data-sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 860px; --smush-placeholder-aspect-ratio: 860\/485;\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"862\" height=\"483\" data-src=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/Screenshot-at-2020-09-14-18-25-28.png\" alt=\"\" class=\"wp-image-716 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Screenshot-at-2020-09-14-18-25-28.png 862w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Screenshot-at-2020-09-14-18-25-28-600x336.png 600w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Screenshot-at-2020-09-14-18-25-28-300x168.png 300w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Screenshot-at-2020-09-14-18-25-28-768x430.png 768w\" data-sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 862px; --smush-placeholder-aspect-ratio: 862\/483;\" \/><\/figure>\n<\/div><\/div>\n\n\n\n<p>Click on &#8220;Close&#8221; after installation is completed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using the display<\/h2>\n\n\n\n<p>We will use one of the standard Adafruit examples to show you the capabilities of the tiny little screen. The example are so straight forward to use, that I find it unnecessary to say anything else about it \ud83d\ude42<\/p>\n\n\n\n<p>Open the ssd1306_128x32_ic2 Example from the Examples menu in the Arduino IDE and upload it to your Arduino, making sure that you set the dimensions of your screen first (in my case 128&#215;32 )<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<pre class=\"wp-block-code\"><code>\/**************************************************************************\n This is an example for our Monochrome OLEDs based on SSD1306 drivers\n\n Pick one up today in the adafruit shop!\n ------> http:\/\/www.adafruit.com\/category\/63_98\n\n This example is for a 128x32 pixel display using I2C to communicate\n 3 pins are required to interface (two I2C and one reset).\n\n Adafruit invests time and resources providing this open\n source code, please support Adafruit and open-source\n hardware by purchasing products from Adafruit!\n\n Written by Limor Fried\/Ladyada for Adafruit Industries,\n with contributions from the open source community.\n BSD license, check license.txt for more information\n All text above, and the splash screen below must be\n included in any redistribution.\n **************************************************************************\/\n\n#include &lt;SPI.h>\n#include &lt;Wire.h>\n#include &lt;Adafruit_GFX.h>\n#include &lt;Adafruit_SSD1306.h>\n\n#define SCREEN_WIDTH 128 \/\/ OLED display width, in pixels\n#define SCREEN_HEIGHT 32 \/\/ OLED display height, in pixels\n\n\/\/ Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)\n#define OLED_RESET     4 \/\/ Reset pin # (or -1 if sharing Arduino reset pin)\nAdafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &amp;Wire, OLED_RESET);\n\n#define NUMFLAKES     10 \/\/ Number of snowflakes in the animation example\n\n#define LOGO_HEIGHT   16\n#define LOGO_WIDTH    16\nstatic const unsigned char PROGMEM logo_bmp&#91;] =\n{ B00000000, B11000000,\n  B00000001, B11000000,\n  B00000001, B11000000,\n  B00000011, B11100000,\n  B11110011, B11100000,\n  B11111110, B11111000,\n  B01111110, B11111111,\n  B00110011, B10011111,\n  B00011111, B11111100,\n  B00001101, B01110000,\n  B00011011, B10100000,\n  B00111111, B11100000,\n  B00111111, B11110000,\n  B01111100, B11110000,\n  B01110000, B01110000,\n  B00000000, B00110000 };\n\nvoid setup() {\n  Serial.begin(9600);\n\n  \/\/ SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally\n  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { \/\/ Address 0x3C for 128x32\n    Serial.println(F(\"SSD1306 allocation failed\"));\n    for(;;); \/\/ Don't proceed, loop forever\n  }\n\n  \/\/ Show initial display buffer contents on the screen --\n  \/\/ the library initializes this with an Adafruit splash screen.\n  display.display();\n  delay(2000); \/\/ Pause for 2 seconds\n\n  \/\/ Clear the buffer\n  display.clearDisplay();\n\n  \/\/ Draw a single pixel in white\n  display.drawPixel(10, 10, SSD1306_WHITE);\n\n  \/\/ Show the display buffer on the screen. You MUST call display() after\n  \/\/ drawing commands to make them visible on screen!\n  display.display();\n  delay(2000);\n  \/\/ display.display() is NOT necessary after every single drawing command,\n  \/\/ unless that's what you want...rather, you can batch up a bunch of\n  \/\/ drawing operations and then update the screen all at once by calling\n  \/\/ display.display(). These examples demonstrate both approaches...\n\n  testdrawline();      \/\/ Draw many lines\n\n  testdrawrect();      \/\/ Draw rectangles (outlines)\n\n  testfillrect();      \/\/ Draw rectangles (filled)\n\n  testdrawcircle();    \/\/ Draw circles (outlines)\n\n  testfillcircle();    \/\/ Draw circles (filled)\n\n  testdrawroundrect(); \/\/ Draw rounded rectangles (outlines)\n\n  testfillroundrect(); \/\/ Draw rounded rectangles (filled)\n\n  testdrawtriangle();  \/\/ Draw triangles (outlines)\n\n  testfilltriangle();  \/\/ Draw triangles (filled)\n\n  testdrawchar();      \/\/ Draw characters of the default font\n\n  testdrawstyles();    \/\/ Draw 'stylized' characters\n\n  testscrolltext();    \/\/ Draw scrolling text\n\n  testdrawbitmap();    \/\/ Draw a small bitmap image\n\n  \/\/ Invert and restore display, pausing in-between\n  display.invertDisplay(true);\n  delay(1000);\n  display.invertDisplay(false);\n  delay(1000);\n\n  testanimate(logo_bmp, LOGO_WIDTH, LOGO_HEIGHT); \/\/ Animate bitmaps\n}\n\nvoid loop() {\n}\n\nvoid testdrawline() {\n  int16_t i;\n\n  display.clearDisplay(); \/\/ Clear display buffer\n\n  for(i=0; i&lt;display.width(); i+=4) {\n    display.drawLine(0, 0, i, display.height()-1, SSD1306_WHITE);\n    display.display(); \/\/ Update screen with each newly-drawn line\n    delay(1);\n  }\n  for(i=0; i&lt;display.height(); i+=4) {\n    display.drawLine(0, 0, display.width()-1, i, SSD1306_WHITE);\n    display.display();\n    delay(1);\n  }\n  delay(250);\n\n  display.clearDisplay();\n\n  for(i=0; i&lt;display.width(); i+=4) {\n    display.drawLine(0, display.height()-1, i, 0, SSD1306_WHITE);\n    display.display();\n    delay(1);\n  }\n  for(i=display.height()-1; i>=0; i-=4) {\n    display.drawLine(0, display.height()-1, display.width()-1, i, SSD1306_WHITE);\n    display.display();\n    delay(1);\n  }\n  delay(250);\n\n  display.clearDisplay();\n\n  for(i=display.width()-1; i>=0; i-=4) {\n    display.drawLine(display.width()-1, display.height()-1, i, 0, SSD1306_WHITE);\n    display.display();\n    delay(1);\n  }\n  for(i=display.height()-1; i>=0; i-=4) {\n    display.drawLine(display.width()-1, display.height()-1, 0, i, SSD1306_WHITE);\n    display.display();\n    delay(1);\n  }\n  delay(250);\n\n  display.clearDisplay();\n\n  for(i=0; i&lt;display.height(); i+=4) {\n    display.drawLine(display.width()-1, 0, 0, i, SSD1306_WHITE);\n    display.display();\n    delay(1);\n  }\n  for(i=0; i&lt;display.width(); i+=4) {\n    display.drawLine(display.width()-1, 0, i, display.height()-1, SSD1306_WHITE);\n    display.display();\n    delay(1);\n  }\n\n  delay(2000); \/\/ Pause for 2 seconds\n}\n\nvoid testdrawrect(void) {\n  display.clearDisplay();\n\n  for(int16_t i=0; i&lt;display.height()\/2; i+=2) {\n    display.drawRect(i, i, display.width()-2*i, display.height()-2*i, SSD1306_WHITE);\n    display.display(); \/\/ Update screen with each newly-drawn rectangle\n    delay(1);\n  }\n\n  delay(2000);\n}\n\nvoid testfillrect(void) {\n  display.clearDisplay();\n\n  for(int16_t i=0; i&lt;display.height()\/2; i+=3) {\n    \/\/ The INVERSE color is used so rectangles alternate white\/black\n    display.fillRect(i, i, display.width()-i*2, display.height()-i*2, SSD1306_INVERSE);\n    display.display(); \/\/ Update screen with each newly-drawn rectangle\n    delay(1);\n  }\n\n  delay(2000);\n}\n\nvoid testdrawcircle(void) {\n  display.clearDisplay();\n\n  for(int16_t i=0; i&lt;max(display.width(),display.height())\/2; i+=2) {\n    display.drawCircle(display.width()\/2, display.height()\/2, i, SSD1306_WHITE);\n    display.display();\n    delay(1);\n  }\n\n  delay(2000);\n}\n\nvoid testfillcircle(void) {\n  display.clearDisplay();\n\n  for(int16_t i=max(display.width(),display.height())\/2; i>0; i-=3) {\n    \/\/ The INVERSE color is used so circles alternate white\/black\n    display.fillCircle(display.width() \/ 2, display.height() \/ 2, i, SSD1306_INVERSE);\n    display.display(); \/\/ Update screen with each newly-drawn circle\n    delay(1);\n  }\n\n  delay(2000);\n}\n\nvoid testdrawroundrect(void) {\n  display.clearDisplay();\n\n  for(int16_t i=0; i&lt;display.height()\/2-2; i+=2) {\n    display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i,\n      display.height()\/4, SSD1306_WHITE);\n    display.display();\n    delay(1);\n  }\n\n  delay(2000);\n}\n\nvoid testfillroundrect(void) {\n  display.clearDisplay();\n\n  for(int16_t i=0; i&lt;display.height()\/2-2; i+=2) {\n    \/\/ The INVERSE color is used so round-rects alternate white\/black\n    display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i,\n      display.height()\/4, SSD1306_INVERSE);\n    display.display();\n    delay(1);\n  }\n\n  delay(2000);\n}\n\nvoid testdrawtriangle(void) {\n  display.clearDisplay();\n\n  for(int16_t i=0; i&lt;max(display.width(),display.height())\/2; i+=5) {\n    display.drawTriangle(\n      display.width()\/2  , display.height()\/2-i,\n      display.width()\/2-i, display.height()\/2+i,\n      display.width()\/2+i, display.height()\/2+i, SSD1306_WHITE);\n    display.display();\n    delay(1);\n  }\n\n  delay(2000);\n}\n\nvoid testfilltriangle(void) {\n  display.clearDisplay();\n\n  for(int16_t i=max(display.width(),display.height())\/2; i>0; i-=5) {\n    \/\/ The INVERSE color is used so triangles alternate white\/black\n    display.fillTriangle(\n      display.width()\/2  , display.height()\/2-i,\n      display.width()\/2-i, display.height()\/2+i,\n      display.width()\/2+i, display.height()\/2+i, SSD1306_INVERSE);\n    display.display();\n    delay(1);\n  }\n\n  delay(2000);\n}\n\nvoid testdrawchar(void) {\n  display.clearDisplay();\n\n  display.setTextSize(1);      \/\/ Normal 1:1 pixel scale\n  display.setTextColor(SSD1306_WHITE); \/\/ Draw white text\n  display.setCursor(0, 0);     \/\/ Start at top-left corner\n  display.cp437(true);         \/\/ Use full 256 char 'Code Page 437' font\n\n  \/\/ Not all the characters will fit on the display. This is normal.\n  \/\/ Library will draw what it can and the rest will be clipped.\n  for(int16_t i=0; i&lt;256; i++) {\n    if(i == '\\n') display.write(' ');\n    else          display.write(i);\n  }\n\n  display.display();\n  delay(2000);\n}\n\nvoid testdrawstyles(void) {\n  display.clearDisplay();\n\n  display.setTextSize(1);             \/\/ Normal 1:1 pixel scale\n  display.setTextColor(SSD1306_WHITE);        \/\/ Draw white text\n  display.setCursor(0,0);             \/\/ Start at top-left corner\n  display.println(F(\"Hello, world!\"));\n\n  display.setTextColor(SSD1306_BLACK, SSD1306_WHITE); \/\/ Draw 'inverse' text\n  display.println(3.141592);\n\n  display.setTextSize(2);             \/\/ Draw 2X-scale text\n  display.setTextColor(SSD1306_WHITE);\n  display.print(F(\"0x\")); display.println(0xDEADBEEF, HEX);\n\n  display.display();\n  delay(2000);\n}\n\nvoid testscrolltext(void) {\n  display.clearDisplay();\n\n  display.setTextSize(2); \/\/ Draw 2X-scale text\n  display.setTextColor(SSD1306_WHITE);\n  display.setCursor(10, 0);\n  display.println(F(\"scroll\"));\n  display.display();      \/\/ Show initial text\n  delay(100);\n\n  \/\/ Scroll in various directions, pausing in-between:\n  display.startscrollright(0x00, 0x0F);\n  delay(2000);\n  display.stopscroll();\n  delay(1000);\n  display.startscrollleft(0x00, 0x0F);\n  delay(2000);\n  display.stopscroll();\n  delay(1000);\n  display.startscrolldiagright(0x00, 0x07);\n  delay(2000);\n  display.startscrolldiagleft(0x00, 0x07);\n  delay(2000);\n  display.stopscroll();\n  delay(1000);\n}\n\nvoid testdrawbitmap(void) {\n  display.clearDisplay();\n\n  display.drawBitmap(\n    (display.width()  - LOGO_WIDTH ) \/ 2,\n    (display.height() - LOGO_HEIGHT) \/ 2,\n    logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1);\n  display.display();\n  delay(1000);\n}\n\n#define XPOS   0 \/\/ Indexes into the 'icons' array in function below\n#define YPOS   1\n#define DELTAY 2\n\nvoid testanimate(const uint8_t *bitmap, uint8_t w, uint8_t h) {\n  int8_t f, icons&#91;NUMFLAKES]&#91;3];\n\n  \/\/ Initialize 'snowflake' positions\n  for(f=0; f&lt; NUMFLAKES; f++) {\n    icons&#91;f]&#91;XPOS]   = random(1 - LOGO_WIDTH, display.width());\n    icons&#91;f]&#91;YPOS]   = -LOGO_HEIGHT;\n    icons&#91;f]&#91;DELTAY] = random(1, 6);\n    Serial.print(F(\"x: \"));\n    Serial.print(icons&#91;f]&#91;XPOS], DEC);\n    Serial.print(F(\" y: \"));\n    Serial.print(icons&#91;f]&#91;YPOS], DEC);\n    Serial.print(F(\" dy: \"));\n    Serial.println(icons&#91;f]&#91;DELTAY], DEC);\n  }\n\n  for(;;) { \/\/ Loop forever...\n    display.clearDisplay(); \/\/ Clear the display buffer\n\n    \/\/ Draw each snowflake:\n    for(f=0; f&lt; NUMFLAKES; f++) {\n      display.drawBitmap(icons&#91;f]&#91;XPOS], icons&#91;f]&#91;YPOS], bitmap, w, h, SSD1306_WHITE);\n    }\n\n    display.display(); \/\/ Show the display buffer on the screen\n    delay(200);        \/\/ Pause for 1\/10 second\n\n    \/\/ Then update coordinates of each flake...\n    for(f=0; f&lt; NUMFLAKES; f++) {\n      icons&#91;f]&#91;YPOS] += icons&#91;f]&#91;DELTAY];\n      \/\/ If snowflake is off the bottom of the screen...\n      if (icons&#91;f]&#91;YPOS] >= display.height()) {\n        \/\/ Reinitialize to a random position, just off the top\n        icons&#91;f]&#91;XPOS]   = random(1 - LOGO_WIDTH, display.width());\n        icons&#91;f]&#91;YPOS]   = -LOGO_HEIGHT;\n        icons&#91;f]&#91;DELTAY] = random(1, 6);\n      }\n    }\n  }\n}<\/code><\/pre>\n\n\n\n<p>I hope that you find this useful and inspiring. <br>Thank you <\/p>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Adding a display to any project can instantly increase its visual appeal, as well as make the project easier to control. Displays available to Electronic enthusiasts mostly include some sort of LCD or even TFT display. LCD displays are usually bulky and very limited in their ability to display a lot of information, whereas &hellip; <a href=\"https:\/\/www.makeriot2020.com\/index.php\/2020\/09\/14\/the-oled-display\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;The OLED Display&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":710,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,74,40,51,16,17,15],"tags":[6,42,67,72,43],"class_list":["post-706","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-displays","category-esp32","category-i2c-devices","category-spi-communication","category-spi-communication-stm32f103c8t6-blue-pill","category-stm32f103c8t6-blue-pill","tag-arduino","tag-esp32","tag-i2c","tag-oled-display","tag-stm32"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/posts\/706","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/comments?post=706"}],"version-history":[{"count":0,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/posts\/706\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/media\/710"}],"wp:attachment":[{"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/media?parent=706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/categories?post=706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/tags?post=706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}