> For the complete documentation index, see [llms.txt](https://cavedu.gitbook.io/cavedu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cavedu.gitbook.io/cavedu/rk005/module_ui/oled.md).

# OLED 顯示器模組

## OLED 顯示器模組 <a href="#hlk168941899" id="hlk168941899"></a>

專案說明

使用「Raspberry Pi Pico W」連接「OLED 顯示器模組」, 可顯示訊息或感測器的數值。此 OLED 顯示器模組包含於「洞洞五教學材料包」內。

### OLED 顯示器模組電路圖

·        Raspberry Pi Pico W

·        Raspberry Pi Pico W 擴充板

·        OLED 顯示器模組

| OLED 顯示器模組是I2C訊號輸入。本範例連接到模組SDA腳位需接至Raspberry Pi Pico擴充板D4腳位，模組SCL腳位需接至Raspberry Pi Pico擴充板D5腳位。 |
| ----------------------------------------------------------------------------------------------- |

<figure><img src="/files/P0aqsArkQ6uAbIqwNoy5" alt=""><figcaption></figcaption></figure>

### &#x20;BlocklyDuino 程式 (OLED)

<figure><img src="/files/nXdmh9EJSuOqKiX4aRKp" alt=""><figcaption></figcaption></figure>

### &#x20; Arduino 程式(OLED.ino)如下

```
#include "Wire.h"
#include "U8g2lib.h"
 
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
 
void setup()
{
  u8g2.begin();
  u8g2.setFont(u8g2_font_6x10_tf);
  u8g2.setFontRefHeightExtendedText();
  u8g2.setDrawColor(1);
  u8g2.setFontPosTop();
  u8g2.setFontDirection(0);
 
  u8g2.clearDisplay();
}
 
void loop()
{
  u8g2.firstPage();
  do {
    u8g2.setCursor(0, 0);
    u8g2.print(String("HELLO").c_str());
    u8g2.drawLine(0, 11, 30, 11);
 
    u8g2.sendBuffer();
  } while (u8g2.nextPage());
}
```

### 程式執行結果:

程式執行結果，會在OLED螢幕中顯示「HELLO」，下面也會顯示底線。

<figure><img src="/files/7KfYhvX5cYJTG9kFW4O2" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cavedu.gitbook.io/cavedu/rk005/module_ui/oled.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
