Difference between revisions of "ArduinoNano 096OLED.ino"

From
Jump to: navigation, search
Line 38: Line 38:
 
VCC - 3V3<br>
 
VCC - 3V3<br>
 
GND - GND<br>
 
GND - GND<br>
SDA - PIN 21<br>
+
SDA - <b>PIN 21</b><br>
SLS - PIN 22<br>
+
SLS - <b>PIN 22</b><br>
  
 
<pre>
 
<pre>

Revision as of 18:46, 31 December 2024

https://wiki.myows.cyou/index.php?title=0.96_OLED

code pour Arduino

#include <Arduino.h>
#include <U8g2lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif

U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0,A5,A4,U8X8_PIN_NONE);

void setup(void) {
  u8g2.begin();
}

void loop(void) {
  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_ncenB08_tr);
  u8g2.drawStr(0,10,"ideaspark 0.96" OLED");
  u8g2.drawStr(0,25,"0.96");
  u8g2.drawStr(0,35,"0.96 inch");
  u8g2.drawStr(0,45,"0.96 inch OLED");
  u8g2.drawStr(0,55,"0.96 inch OLED 128x64");
  u8g2.sendBuffer();
  delay(1000);
}


code pour ESP32 testé avec la carte 30 PIN de Aliexpress

VCC - 3V3
GND - GND
SDA - PIN 21
SLS - PIN 22

#include <Arduino.h>
#include <U8g2lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif

U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0,22,21,U8X8_PIN_NONE);

void setup(void) {
  u8g2.begin();
}

void loop(void) {
  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_ncenB08_tr);
  u8g2.drawStr(0,10,"0.96 OLED ligne 10");
  u8g2.drawStr(0,25,"0.96 inch ligne 25");
  u8g2.drawStr(0,35,"0.96 inch ligne 35");
  u8g2.drawStr(0,45,"0.96 inch OLED ligne 45");
  u8g2.drawStr(0,55,"0.96 inch OLED 128x64");
  u8g2.sendBuffer();
  delay(1000);
}