{"id":3176,"date":"2025-10-01T22:28:11","date_gmt":"2025-10-01T20:28:11","guid":{"rendered":"http:\/\/arduino.net.pl\/?p=3176"},"modified":"2025-10-03T21:51:03","modified_gmt":"2025-10-03T19:51:03","slug":"wyswietlacz-oled-0-91-128-x-32-px","status":"publish","type":"post","link":"https:\/\/arduino.net.pl\/index.php\/wyswietlacz-oled-0-91-128-x-32-px\/","title":{"rendered":"Wy\u015bwietlacz OLED 0.91 inch 128 x 32 px"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">ARDUINO<\/h2>\n\n\n\n<h5 class=\"wp-block-heading\">BIBLIOTEKA<\/h5>\n\n\n\n<p>Te same \u015bwietne <a href=\"https:\/\/learn.adafruit.com\/monochrome-oled-breakouts\/arduino-library-and-examples?gclid=Cj0KCQjwjOrtBRCcARIsAEq4rW5pP16fAkUUcKxDAP1rfMXh9qwF9ig0HWEj7V0-QF6DeH-AxATk86YaAvLFEALw_wcB\">biblioteki<\/a> pani <strong>Ady Owocowej<\/strong>, kt\u00f3rych u\u017cywa\u0142em z <a href=\"http:\/\/arduino.net.pl\/index.php\/128x64-led-display-module-for-arduino\/\">OLED 128&#215;64<\/a>. Naturalnie w <strong>Examples<\/strong> nale\u017cy wybra\u0107 pozycj\u0119 <strong>ssd1306_128x32_i2c<\/strong><\/p>\n\n\n\n<h5 class=\"wp-block-heading\">KOD<\/h5>\n\n\n\n<p>Napisa\u0142em prosty program testowy, kt\u00f3ry rysuje linie z pikseli.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; light: false; title: Kod:; toolbar: true; notranslate\" title=\"Kod:\">\n\/**************************************************************************\n  This is an example for our Monochrome OLEDs based on SSD1306 drivers\n\n  Pick one up today in the adafruit shop!\n  ------&gt; 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\n#include &lt;SPI.h&gt;\n#include &lt;Wire.h&gt;\n#include &lt;Adafruit_GFX.h&gt;\n#include &lt;Adafruit_SSD1306.h&gt;\n\n#define SCREEN_WIDTH 128 \/\/ OLED display width, in pixels\n#define SCREEN_HEIGHT 32 \/\/ OLED display height, in pixels\n\n\n\/\/ Nano I2C; SDA -&gt; A4; SCL -&gt; A5\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\nboolean flag = 0;\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(&quot;SSD1306 allocation failed&quot;));\n    for (;;); \/\/ Don&#039;t proceed, loop forever\n  }\n\n  display.clearDisplay();\n}\n\nvoid loop() {\n\ndisplay.invertDisplay(flag);\n  \n  \/\/ Draw a single pixel in white\n  for (int y = 10; y &lt; 26; y = y + 2) {\n    for (int x = 10; x &lt; 120; x = x + 1) {\n      display.display();\n      display.drawPixel(x, y, WHITE);\n      \/\/delay(5);    \n    }\n  }\n  delay(5000);\n  display.clearDisplay();\n  if(!flag){flag = true;}else{flag = false;}\n}\n\n<\/pre><\/div>\n\n\n<p><strong>UWAGA!<\/strong><br>Funkcja <code>display.clearDisplay()<\/code> czasem nie czy\u015bci ekranu. Tak si\u0119 dzia\u0142o przy jednym z moich projekt\u00f3w z ESP8266 NodeMCU. Wtedy nale\u017cy doda\u0107 funkcj\u0119 <code>display.display()<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void screenErase(){  \n  Serial.println(\"Wymazuj\u0119 ekran\");\n  display.clearDisplay();\n  display.display();\n}<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">MicroPython<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>YT film:\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/youtu.be\/4UXQOkU3q8s?si=nqKhZhml4iJ9CQAi\" title=\"\">https:\/\/youtu.be\/4UXQOkU3q8s?si=nqKhZhml4iJ9CQAi<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>biblioteka:\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/raw.githubusercontent.com\/RuiSantosdotme\/ESP-MicroPython\/master\/code\/Others\/OLED\/ssd1306.py\" title=\"biblioteka\">https:\/\/raw.githubusercontent.com\/RuiSantosdotme\/ESP-MicroPython\/master\/code\/Others\/OLED\/ssd1306.py<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h5 class=\"wp-block-heading\">I KOD<\/h5>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; light: false; title: Kod:; toolbar: true; notranslate\" title=\"Kod:\">\nfrom machine import Pin, SoftI2C\nimport time\nfrom ssd1306 import SSD1306_I2C   # zak\u0142adam \u017ce bibliotek\u0119 zapisa\u0142e\u015b jako ssd1306.py\n\n# konfiguracja I2C (dla ESP32-S3 mo\u017cna u\u017cy\u0107 SoftI2C albo I2C)\ni2c = SoftI2C(scl=Pin(22), sda=Pin(21))\n\n# sprawdzanie urz\u0105dze\u0144 na I2C\nprint(&quot;I2C scan:&quot;, i2c.scan())   # powinno pokaza\u0107 &#x5B;60] czyli 0x3C\n\n# inicjalizacja OLED 128x64\noled = SSD1306_I2C(128, 64, i2c)\n\n# testowe wy\u015bwietlanie napisu\noled.fill(0)   # wyczy\u015b\u0107 ekran\noled.text(&quot;Hello ESP32-S3&quot;, 0, 0)\noled.text(&quot;MicroPython OLED&quot;, 0, 16)\noled.text(&quot;128x64 I2C Test&quot;, 0, 32)\noled.show()\n\n# miganie napisem co sekund\u0119\nwhile True:\n    oled.fill(0)\n    oled.text(&quot;ON&quot;, 50, 28)\n    oled.show()\n    time.sleep(1)\n\n    oled.fill(0)\n    oled.text(&quot;OFF&quot;, 50, 28)\n    oled.show()\n    time.sleep(1)\n\n<\/pre><\/div>\n\n\n<h5 class=\"wp-block-heading\">II KOD <\/h5>\n\n\n\n<p>Dla mikrokontrolera <strong>ESP32-S3<\/strong>, wykorzystuj\u0105cy  sprz\u0119towe <code>I2C<\/code> . ESP32-S3 ma <strong>dwa kontrolery I2C sprz\u0119towe<\/strong> (<code>I2C(0)<\/code> i <code>I2C(1)<\/code>). Mo\u017cemy je przypisa\u0107 do prawie dowolnych pin\u00f3w (mux pin\u00f3w jest elastyczny). R\u00f3\u017cnica mi\u0119dzy <code>SoftI2C<\/code> a <code>I2C<\/code> jest taka, \u017ce <code>I2C<\/code> korzysta z kontrolera sprz\u0119towego, a <code>SoftI2C<\/code> to programowa emulacja. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; light: false; title: Kod:; toolbar: true; notranslate\" title=\"Kod:\">\nfrom machine import Pin, I2C\nfrom ssd1306 import SSD1306_I2C\nimport time\n\n# u\u017cywamy kontrolera I2C(0) lub I2C(1)\n# tutaj: I2C(1), GPIO9 = SCL, GPIO8 = SDA\ni2c = I2C(1, scl=Pin(9), sda=Pin(8), freq=400000)  # 400kHz\n\nprint(&quot;I2C scan:&quot;, i2c.scan())  # powinno pokaza\u0107 &#x5B;60]\n\noled = SSD1306_I2C(128, 64, i2c)\n\noled.fill(0)\noled.text(&quot;Sprzetowe I2C&quot;, 0, 0)\noled.text(&quot;SCL=9 SDA=8&quot;, 0, 16)\noled.show()\n\n# prosty test z miganiem napisu\nwhile True:\n    oled.fill(0)\n    oled.text(&quot;ON&quot;, 50, 28)\n    oled.show()\n    time.sleep(1)\n\n    oled.fill(0)\n    oled.text(&quot;OFF&quot;, 50, 28)\n    oled.show()\n    time.sleep(1)\n\n<\/pre><\/div>\n\n\n<p style=\"text-decoration:underline\"><strong>Kilka uwag<\/strong>:<\/p>\n\n\n\n<p>Nale\u017cy <strong>uwa\u017ca\u0107 na piny<\/strong> w wy\u015bwietlaczach. Posiadam <strong>kilka wy\u015bwietlaczy<\/strong> i w niekt\u00f3rych kolejno\u015b\u0107 pin\u00f3w to <strong>VCC, GND<\/strong>, a w innych jest to <strong>GND, VCC<\/strong>. <strong>Ma\u0142o brakowa\u0142o, a jeden spali\u0142bym<\/strong> przez pomy\u0142k\u0119. Trzeba jednak przyzna\u0107, \u017ce s\u0105 one <strong>do\u015b\u0107 wytrzyma\u0142e<\/strong>! ;) <br>Druga sprawa to <strong>I2C<\/strong>. Je\u015bli <strong>nic nie wida\u0107 na ekraniku<\/strong>, najprawdopodobniej <strong>pomylili\u015bmy piny SDA z SCL<\/strong>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h5 class=\"wp-block-heading\">LINKI<\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/codepen.io\/KjeldSchmidt\/pen\/KaRPzX\">Edytor OLED Arduino Code Pen<\/a><\/li>\n\n\n\n<li><a href=\"http:\/\/javl.github.io\/image2cpp\/\">Edytor obraz\u00f3w OLED 128<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/iotbyhvm.ooo\/esp32-with-oled-interfacing-oled-with-esp32-using-arduino-ide\/\">ESP32 with OLED | Interfacing OLED with ESP32 using Arduino IDE<\/a>  \/dobra strona<\/li>\n\n\n\n<li><a href=\"https:\/\/learn.adafruit.com\/adafruit-gfx-graphics-library\/overview\">Adafruit GFX Graphics Library<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/diyprojects.io\/using-i2c-128x64-0-96-ssd1306-oled-display-arduino\/#.XbtQ4y2Birw\">How to display text, image and animation on an OLED screen SSD1306 I2C 128\u00d764 0.96 \u201cwith an Arduino<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/lastminuteengineers.com\/oled-display-arduino-tutorial\/\">Interface OLED Graphic Display Module with Arduino<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.instructables.com\/id\/OLED-I2C-Display-ArduinoNodeMCU-Tutorial\/\" target=\"_blank\" rel=\"noreferrer noopener\">OLED I2C Display Arduino\/NodeMCU Tutorial<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>ARDUINO BIBLIOTEKA Te same \u015bwietne biblioteki pani Ady Owocowej, kt\u00f3rych u\u017cywa\u0142em z OLED 128&#215;64. Naturalnie w Examples nale\u017cy wybra\u0107 pozycj\u0119 ssd1306_128x32_i2c KOD Napisa\u0142em prosty program testowy, kt\u00f3ry rysuje linie z&#8230;<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-3176","post","type-post","status-publish","format-standard","hentry","category-arduino"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/posts\/3176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/comments?post=3176"}],"version-history":[{"count":26,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/posts\/3176\/revisions"}],"predecessor-version":[{"id":6619,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/posts\/3176\/revisions\/6619"}],"wp:attachment":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/media?parent=3176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/categories?post=3176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/tags?post=3176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}