|
|
|
|
● Additional Boards Manager URLs https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
![]() Waveshare RP2040-Zero 高性能ピコライクMCUボード Raspberry PiマイクロコントローラーRP2040 カステレーションモジュールでキャリアボードに直接はんだ付け可能 - 2個 ASIN: B0B2Z3YWB9 |
![]() KKHMF 20個 USB タイプA メスソケット ブレイクアウトボード 4Pアダプタコネクタ 2.54mm ソルダープリント DIY 基板 ブレッドボード 電源 ASIN: B099PCM2D2 |
![]() ARCELI 20値0805SMD抵抗器アソートメントキットSMD抵抗器各20合計400 ASIN: B07RTH6JHX ※ 22Ωの抵抗が必要だから |
![]() GAOHOU 5個 0.42インチ 4ピン OLEDディスプレイ SSD1306 LCD IICインタフェースモジュール 白表示 ASIN: B0CDC6VSKC ※ I2C OLED SSD1306 |




//------------------------------------------------------------------------------
// this section is based on 72x40 Micro OLED display (by r7)
/** Initialization commands for a 72x40 SSD1306 0.42 inch oled display. */
static const uint8_t MEM_TYPE MicroOLED72x40init[] = {
// Init sequence for 72x40 Micro OLED module
// Model:TOX042TSWPG01 0.42" OLED Display Module (72*40)
// 4.4 Actual Application Example <Power up Sequence>
/*
// SSD1315
SSD1306_DISPLAYOFF,
SSD1306_SETDISPLAYCLOCKDIV, 0xF0, // the suggested ratio 0x80
SSD1306_SETMULTIPLEX, 0x27, // (DISPLAYHEIGHT - 1)
SSD1306_SETDISPLAYOFFSET, 0x0, // no offset
SSD1306_SETSTARTLINE, // line #0
SSD1306_CHARGEPUMP, 0x95, // internal vcc
SSD1306_SEGREMAP | 0x1, // column 127 mapped to SEG0
SSD1306_COMSCANDEC, // column scan direction reversed
SSD1306_SETCOMPINS, 0x12, // 0x12 if height > 32 else 0x02
SSD1306_SETCONTRAST, 0xAF, // contrast level 127
SSD1306_SETPRECHARGE, 0x1F, // pre-charge period (1, 15)
SSD1306_SETVCOMDETECT, 0x20, // vcomh regulator level
SSD1306_NORMALDISPLAY,
SSD1306_DISPLAYALLON_RESUME,
SSD1306_DISPLAYON
*/
// SSD1306
SSD1306_DISPLAYOFF,
SSD1306_SETDISPLAYCLOCKDIV, 0x80, // the suggested ratio 0x80
SSD1306_SETMULTIPLEX, 0x27, // (DISPLAYHEIGHT - 1)
SSD1306_SETDISPLAYOFFSET, 0x0, // no offset
SH1106_SET_PUMP_MODE, 0x030, // Internal IREF Setting for the 0.42 OLED, see also issue https://github.com/olikraus/u8g2/issues/1047
SSD1306_CHARGEPUMP, 0x14, // internal vcc
SSD1306_SETSTARTLINE, // line #0
SSD1306_NORMALDISPLAY,
SSD1306_DISPLAYALLON_RESUME,
SSD1306_MEMORYMODE, 0x00,
SSD1306_SEGREMAP | 0x1, // column 127 mapped to SEG0
SSD1306_COMSCANDEC, // column scan direction reversed
SSD1306_SETCOMPINS, 0x12, // 0x12 if height > 32 else 0x02
SSD1306_SETCONTRAST, 0x5F, // contrast level 127
SSD1306_SETPRECHARGE, 0x22, // pre-charge period (1, 15)
SSD1306_SETVCOMDETECT, 0x20, // vcomh regulator level
SSD1306_DISPLAYON
};
/** Initialize a 72x40 Micro OLED display. */
static const DevType MEM_TYPE MicroOLED72x40 = {
MicroOLED72x40init,
sizeof(MicroOLED72x40init),
72,
40,
28 // Use middle 72 columns. (128 - 72) / 2
};
// clang-format on
#endif // SSD1306init_h
※ 72x40の場合、黄色行の SH1106_SET_PUMP_MODE, 0x030, が必要です。
// Waveshare RP2040-Zero
#include "SSD1306Ascii.h"
#include "SSD1306AsciiWire.h"
// 0X3C+SA0 - 0x3C or 0x3D
#define I2C_ADDRESS 0x3C
// Define proper RST_PIN if required.
#define RST_PIN -1
SSD1306AsciiWire oled;
void setup() {
// put your setup code here, to run once:
// Select IO pins to use. Call before ::begin()
Wire.setSDA(28);
Wire.setSCL(29);
Wire.begin();
// SCL tcycle Clock Cycle Time = 2.5us = 400kHz
Wire.setClock(400000L); // 400kHz
// SSD1306 72*40 0.42' MicroOLED72x40
#if RST_PIN >= 0
oled.begin(&MicroOLED72x40, I2C_ADDRESS, RST_PIN);
#else // RST_PIN >= 0
oled.begin(&MicroOLED72x40, I2C_ADDRESS);
#endif // RST_PIN >= 0
// Call oled.setI2cClock(frequency) to change from the default frequency.
oled.setFont(System5x7);
oled.clear();
oled.println("Hello world!");
oled.println("123456789012");
oled.println("333333333333");
oled.println("444444444444");
oled.println("555555555555");
oled.setContrast(32);
}
void loop() {
// put your main code here, to run repeatedly:
oled.clear();
delay(500);
oled.println("Hello world!");
oled.println("123456789012");
oled.println("333333333333");
oled.println("444444444444");
oled.println("555555555555");
delay(500);
}