{"id":2277,"date":"2024-07-16T13:10:22","date_gmt":"2024-07-16T13:10:22","guid":{"rendered":"https:\/\/iotthinghub.com\/?p=2277"},"modified":"2024-08-11T17:58:30","modified_gmt":"2024-08-11T17:58:30","slug":"oled-ssd1306-interfacing","status":"publish","type":"post","link":"https:\/\/iotthinghub.com\/?p=2277","title":{"rendered":"OLED (SSD1306) interfacing"},"content":{"rendered":"\n<p class=\"has-text-color has-link-color wp-elements-b878999f6460549fb62f2f5b3a5dde40 wp-block-paragraph\" style=\"color:#5c5c5c\">OLED is an Organic Light Emitting Diodes. OLED is a flat emitting technology based screen. OLEDs are emissive display that does not require a backlight, so are thinner and more efficient and LCD display which require a white backlight. OLED display are not just thin and efficient, they provide the best image quality ever as LED and LCD and they can also be made transparent, foldable, flexible and even roll able and stretchable in the figure. The pin out are-<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"175\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/OLED-1024x175.jpg\" alt=\"\" class=\"wp-image-2280\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/OLED-1024x175.jpg 1024w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/OLED-300x51.jpg 300w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/OLED-768x131.jpg 768w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/OLED.jpg 1360w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-449998e1e885a77ad956c96785e10e5f wp-block-paragraph\" style=\"color:#5c5c5c\">Here the driver IC used is SSD1306 which has its I<sup>2<\/sup>C protocol. Let\u2019s first look the I<sup>2<\/sup>C write protocol<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"558\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/datasheet-7-1024x558.jpg\" alt=\"\" class=\"wp-image-2282\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/datasheet-7-1024x558.jpg 1024w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/datasheet-7-300x163.jpg 300w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/datasheet-7-768x419.jpg 768w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/datasheet-7.jpg 1402w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-9c1220cb824b47290e182f1d39a096c8 wp-block-paragraph\" style=\"color:#5c5c5c\">The slave address is 0b011110SA0R\/W where SA0 bit provide an extension bit for slave address. Either \u20180111100\u2019 or \u20180111101\u2019 can be selected as slave address of SSD1306. Here bit7 C0 determines the continuation and bit6 D\/C represent data or command. D\/C = 1 \u2013 Data mode and D\/C = 0 \u2013 Command mode. So for command mode 0x80 and for data mode 0x40. Write function for OLED is<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-upper-heading-font-size wp-elements-245f23b5762564304f460ff0fef5d3fa wp-block-paragraph\" style=\"color:#6c8a97\">void I2C_Write_OLED(unsigned char addr, unsigned char data) -&gt; Both Data or CMD<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\nvoid I2C_Write_OLED(unsigned char addr,unsigned char data)\n{    \n  I2C_Start();                       \/\/ Start condition                            \n  I2C_Write(SLAVE_ADDR_ACC | WRITE); \/\/ Write SW+ADD+Write = 0b01111000\n  I2C_Write(addr);                   \/\/ Write Address\n  I2C_Write(data);                   \/\/ Write data \n  I2C_Stop();                        \/\/ Stop Communication  \n}\n<\/pre><\/div>\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-7387b849 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"has-text-color has-link-color wp-elements-5fb75d8cfb0222162b0a5936dfa4494d wp-block-paragraph\" style=\"color:#5c5c5c\">void sendcommand(unsigned char com) -&gt; cmd function<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\nvoid sendcommand(unsigned char com)\n{\n\tI2C_Write_OLED(OLED_COMMAND,com);\n}\n<\/pre><\/div><\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p class=\"has-text-color has-link-color wp-elements-01a71a95d51c8dbaa3336f217770fc99 wp-block-paragraph\" style=\"color:#5c5c5c\">void SendChar(unsigned char data) -&gt; character send<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\nvoid SendChar(unsigned char data)\n{\n\tI2C_Write_OLED(OLED_DATA,data);\n}\n<\/pre><\/div><\/div>\n<\/div>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-3ab4f33230877e90e894598117358b41 wp-block-paragraph\" style=\"color:#5c5c5c\">Set the default setting of OLED. The OLED has 128&#215;64 or 128&#215;32 bit pixel. The OLED is nothing but a set of pixel or dot. Let\u2019s look at the pixel mapping \u2013<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"323\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/datasheet-8-1024x323.jpg\" alt=\"\" class=\"wp-image-2306\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/datasheet-8-1024x323.jpg 1024w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/datasheet-8-300x95.jpg 300w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/datasheet-8-768x242.jpg 768w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/datasheet-8.jpg 1388w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-05ce004fbf0eae6439192320b475428d wp-block-paragraph\" style=\"color:#5c5c5c\">From the pixel pattern, it has been shown that for 128&#215;64 size OLED has 0-7 pages and 0-127 columns available. For 128&#215;32 size OLED has 0-3 pages and 0-127 columns. If we want to write character of 8&#215;8 pixel mapping then we have 0-7 pages or 8 lines. Let\u2019s print a logo of 128*8piel bitmap, since a picture is nothing but a set of pixel bitmap. If we put the logo of twitter in pixel bitmap of 128*64, then value of the variable is-<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\nconst unsigned char Technology&#x5B;] PROGMEM = {\n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xff, 0x7f, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x3f, 0x3f, \n\t0x3f, 0x3f, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0x7f, 0xff, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0x7f, 0x7f, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfc, 0xfc, 0xfc, 0xfe, \n\t0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xff, 0xfd, 0xff, 0xfb, 0xff, 0xf7, \n\t0xf7, 0xf6, 0xf6, 0xf5, 0xf5, 0xf5, 0xf5, 0xd5, 0x15, 0xd5, 0xf5, 0x95, 0x15, 0x15, 0x37, 0x73, \n\t0xf7, 0x17, 0x57, 0x75, 0x10, 0xf0, 0x10, 0x90, 0xbc, 0x19, 0x9d, 0x9f, 0x9c, 0x9c, 0x1c, 0x9e, \n\t0x9e, 0x1c, 0x7c, 0x1c, 0x1f, 0xfd, 0x19, 0x7c, 0x70, 0x30, 0xf0, 0x10, 0x55, 0x57, 0x17, 0xf7, \n\t0x13, 0x17, 0x35, 0x15, 0xb5, 0x95, 0x95, 0x35, 0x95, 0xd5, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf7, \n\t0xf7, 0xff, 0xfb, 0xff, 0xfd, 0xff, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, \n\t0xfe, 0xfc, 0xfc, 0xfc, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xe7, 0xe3, 0xe3, 0xe3, 0xe7, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0x9f, 0xdf, 0xdf, 0xd7, 0xdf, 0xdb, 0xdf, 0xdd, 0xdd, 0xef, \n\t0xef, 0xff, 0xf7, 0xff, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfd, \n\t0xfd, 0xff, 0xff, 0xf3, 0xf0, 0xf0, 0xf1, 0xf0, 0xf1, 0xf9, 0xff, 0xf3, 0xf3, 0xc3, 0x47, 0x47, \n\t0x47, 0x47, 0xc7, 0xf3, 0xf3, 0xff, 0xfb, 0xf1, 0xf0, 0xf1, 0xf0, 0xf0, 0xf3, 0xff, 0xff, 0xfd, \n\t0xfd, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xff, 0xf7, 0xff, 0xef, \n\t0xef, 0xfd, 0xdd, 0xdf, 0xdb, 0xdf, 0xd7, 0xdf, 0xdf, 0x9f, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xe7, 0xe3, 0xe3, 0xe3, 0xe7, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfe, 0xfe, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xff, \n\t0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xfe, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \n\t0x0f, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, \n\t0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, \n\t0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, \n\t0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, \n\t0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, \n\t0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, \n\t0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, \n\t0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x0f, 0x1f, 0x1f, 0x1f, 0x0f\n};\n<\/pre><\/div>\n\n\n<p class=\"has-text-color has-link-color wp-elements-437902b5fa97e45a9a24c859017ba70f wp-block-paragraph\" style=\"color:#5c5c5c\">So the function is simple, just send the pixel bitmap into the OLED-<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-upper-heading-font-size wp-elements-164eea1b6e21a64181eed01d36770dc2 wp-block-paragraph\" style=\"color:#6c8a97\">void logo_write(void) -&gt; Logo write<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\n void logo_write(uint8_t screen)\n{\n\tfor(int i=0;i&lt;128*8;i++)     \/\/ show 128* 64 Logo\n\tSendChar(pgm_read_byte(Technology +i));\n}\n<\/pre><\/div>\n\n\n<p class=\"has-text-color has-link-color wp-elements-eb225ead03a7dc308084c4c682a81e3f wp-block-paragraph\" style=\"color:#5c5c5c\">How the characters are writing into the OLED? Since it has 8 pages the pages are write in sequentially. Let\u2019s look at page 2 for more details.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"295\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/datasheet-9-1024x295.jpg\" alt=\"\" class=\"wp-image-2308\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/datasheet-9-1024x295.jpg 1024w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/datasheet-9-300x87.jpg 300w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/datasheet-9-768x222.jpg 768w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/datasheet-9.jpg 1404w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-9af4144a3bfee0a735c9fcec6473fa84 wp-block-paragraph\" style=\"color:#5c5c5c\">There are 3 different memory addressing mode in SSD1306: page addressing mode, horizontal addressing mode and vertical addressing mode. We use the page addressing mode. In normal display data RAM read or write and page addressing mode, the following steps are required to define the starting RAM access pointer location:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"102\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/table-9-1024x102.jpg\" alt=\"\" class=\"wp-image-2296\" style=\"width:683px;height:auto\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/table-9-1024x102.jpg 1024w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/table-9-300x30.jpg 300w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/table-9-768x76.jpg 768w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/table-9.jpg 1306w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-7f34769e5c314402fd12185e8abc6252 wp-block-paragraph\" style=\"color:#5c5c5c\">So the pixel location user defined function as follow-<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-upper-heading-font-size wp-elements-c48bd526496eaaf3bc66e6512a741fdc wp-block-paragraph\" style=\"color:#6c8a97\">void setXY(unsigned char row,unsigned char col) -&gt; (x,y) coordinate<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\nvoid setXY(unsigned char row,unsigned char col)\n{\n  sendcommand(0xb0+row);                \/\/set page address\n  sendcommand(0x00+(8*col&amp;0x0f));       \/\/set low col address\n  sendcommand(0x10+((8*col&gt;&gt;4)&amp;0x0f));  \/\/set high col address\n}\n<\/pre><\/div>\n\n\n<p class=\"has-text-color has-link-color wp-elements-08a24bfd746b48bf9f577e543728f51c wp-block-paragraph\" style=\"color:#5c5c5c\">Since the OLED has no build in ASCII character. So we have to make our own character for display ASCII character. Let use 8&#215;8 size character, so to display \u2018B\u2019 which is ASCII 0x42 is-<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"370\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/table-10-1024x370.jpg\" alt=\"\" class=\"wp-image-2300\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/table-10-1024x370.jpg 1024w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/table-10-300x108.jpg 300w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/table-10-768x278.jpg 768w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/07\/table-10.jpg 1300w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-ff8fe4fb96ff8e731e8c0d8404f35134 wp-block-paragraph\" style=\"color:#5c5c5c\">Similarly other character can be generated. Build your own front with big or small as you want. Now we have the \u2018B\u2019 character, but how to write in exact location you want? Use the following function.<\/p>\n\n\n\n<p class=\"has-text-color has-link-color has-upper-heading-font-size wp-elements-b2b1613ecd0ad9c4d9c4130ce8e1a6a4 wp-block-paragraph\" style=\"color:#6c8a97\">void OLCD_write_string(int X, int Y, char *string) -&gt; String write function<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\nconst uint8_t myFont&#x5B;8] PROGMEM = { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x00, 0x00}\nvoid OLCD_write_string(int X, int Y, char *string)\n{\n  setXY(X,Y);\n  unsigned char i=0;\n  while(*string)\n  {\n    for(i=0;i&lt;8;i++)\n    {\n      SendChar(pgm_read_byte(myFont&#x5B;*string-0x20]+i));\n    }\n    *string++;\n  }\n}\n<\/pre><\/div>\n\n\n<p class=\"has-text-color has-link-color wp-elements-8858310b771c38945b0e0950e69b8eed wp-block-paragraph\" style=\"color:#5c5c5c\">To clear display just sends 0 to all pixels and according to bitmap pattern you can write any shape or image into the OLED. We have written a simple program to display some logo and string into the display. The code is written in ATmega328p just download and connect SDA to SDA and SCL to SCL pin, VCC and ground as usual.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-7387b849 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:33.33%\">\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-3e41869c wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/OLED-128into64-pixel.rar\" style=\"padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--40)\">download<\/a><\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:66.66%\">\n<p class=\"has-text-color has-link-color has-upper-heading-font-size wp-elements-cca89d90222ca8793e1cf49a5b44334d wp-block-paragraph\" style=\"color:#252525\"><a href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/OLED-128into64-pixel.rar\">OLED 128into64 pixel.rar<\/a><\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>OLED is an Organic Light Emitting Diodes. OLED is a flat emitting technology based screen. OLEDs are emissive display that does not require a backlight, so are thinner and more efficient and LCD display which require a white backlight. OLED display are not just thin and efficient, they provide the best image quality ever as [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-2277","post","type-post","status-publish","format-standard","hentry","category-i2c"],"_links":{"self":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts\/2277","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2277"}],"version-history":[{"count":18,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts\/2277\/revisions"}],"predecessor-version":[{"id":2650,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts\/2277\/revisions\/2650"}],"wp:attachment":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}