📘 Start here first: #0 Start Here Tutorial. Finish connecting your board and doing your first upload there, then come back.Intro
Hi! I'm Emily from Nucode, the team in Korea that makes the NU40 DK board 👋
When I ran Doom on the NU40 DK, built a character that copies my facial expressions, and made a stock ticker for my desk, they all had one thing in common: a tiny OLED screen, about the size of a fingernail.
Every one of those projects needs the screen first, so I pulled that step out into its own short post.
By the end, your OLED will be connected to the board and showing "Hello, NU40 DK!". No soldering. You only need 4 jumper wires.
- Difficulty: Easy
- Time: 20 min
- OS: Windows · macOS · Linux
- You need: NU40 DK, a USB-C data cable, a 0.96" 128×64 SSD1306 OLED with an I2C (4-pin) interface, and 4 jumper wires
Code (Arduino IDE) --USB upload--> NU40 DK --I2C (2 wires: SDA, SCL)--> OLED screen- I2C is a way for a board to talk to several parts over just 2 wires: SDA (data) and SCL (clock, the "beat" both sides follow). Every part has an address, so the board calls out "part 0x3C!" and then talks to it.
- The OLED's address is usually
0x3C. The motion sensor (IMU) that's already on the board is0x6A. They share the same two wires. - The other 2 wires (VCC and GND) power the screen.
🛑 Unplug the USB cable before wiring. Connect the OLED's VCC to the board's VMOD pin. VMOD is the pin that supplies 3.3 V on this board. If you swap VCC and GND, the module gets hot and your computer may cut USB power.
Connect the 4 pins like this. The board pin names are exactly what's printed on the board, and the numbers count along the right-side header.
- OLED GND → board GND (right header, pin 24)
- OLED SDA → board P0.26 (pin 25)
- OLED SCL → board P0.27 (pin 26)
- OLED VCC → board VMOD (pin 27)
- On the right header, pin 31 is the end closest to the USB port. Below pin 27 (VMOD), toward the USB port, come VBAT, GND, VDDH and VBUS. If you count from the wrong end, every wire ends up in the wrong place.
- The pin order is different on different OLED modules. Always read the labels on your module (usually printed next to the pins)
Before turning the screen on, let's check that the board can see the OLED.
- Open File → New Sketch, delete everything, and copy the code below into Arduino IDE.
- Click Upload (→).
- When the upload is done, open Tools → Serial Monitor and set the speed on the right to 115200.
#include <Adafruit_TinyUSB.h>
#include <Wire.h>
void setup() {
Serial.begin(115200);
while (!Serial) delay(10); // wait until Serial Monitor is open
Wire.begin(); // SDA = P0.26, SCL = P0.27 by default
Serial.println("Scanning I2C...");
for (uint8_t addr = 1; addr < 127; addr++) {
Wire.beginTransmission(addr);
if (Wire.endTransmission() == 0) {
Serial.print("Found 0x");
Serial.println(addr, HEX);
}
}
Serial.println("Done");
}
void loop() {}What the code doesWire.begin(): turns on I2C. On this board, SDA and SCL are already set to P0.26 and P0.27.- The
forloop calls every address from 1 to 126 and asks "anyone there?" If a part answers (== 0), it prints that address.
Reading the result:
0x3Cand0x6A: ✅ Success! 0x3C is the OLED, 0x6A is the board's built-in motion sensor (IMU).- Only
0x6A: the board is fine, but the OLED wiring is wrong. See Troubleshooting below. - Nothing, or it stops partway: see Troubleshooting below.
First, install the library. A library is a bundle of code someone else already wrote. This one handles the complicated parts of driving the OLED for you.
- Click Library Manager in the left sidebar (the icon that looks like books).
- Type
Adafruit SSD1306in the search box and click INSTALL. - When a window asks whether to install the libraries it depends on, click INSTALL ALL. (This also installs Adafruit GFX.)
Then open a new sketch, copy the code below into Arduino IDE, and click Upload (→).
// NU40 DK - Hello OLED
// Shows "Hello, NU40 DK!" on a 0.96" SSD1306 128x64 I2C OLED.
// Wiring: GND-GND, SDA-P0.26, SCL-P0.27, VCC-VMOD (3.3 V)
#include <Adafruit_TinyUSB.h> // required on this board
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// Last two numbers = I2C speed (400 kHz). Set it here; Wire.setClock() is ignored.
Adafruit_SSD1306 display(128, 64, &Wire, -1, 400000, 400000);
void setup() {
// Always pass the address 0x3C (use 0x3D if your scan shows that).
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
pinMode(PIN_LED1, OUTPUT);
digitalWrite(PIN_LED1, HIGH); // LED1 on = OLED not found
while (true) delay(100);
}
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.println("Hello,");
display.println("NU40 DK!");
display.display();
}
void loop() {}What the code doesAdafruit_SSD1306 display(...): sets up a 128×64 screen on I2C. The400000, 400000at the end is the communication speed (400 kHz).display.begin(..., 0x3C): turns the screen on. If that fails, it lights LED1 and stops.clearDisplay(),setTextSize(),setCursor(),println(): draw text into the screen's memory.display.display(): sends what you drew to the actual screen. Without this line, nothing shows up.
✅ Checkpoint: The OLED shows "Hello, NU40 DK!" 🎉
- Text size: In
display.setTextSize(2);, change2to1(small, about 21 characters per line) or3(big). - Message: Replace
"Hello,"and"NU40 DK!"with your own text. - Position: The numbers in
display.setCursor(0, 0);are the (x, y) pixel position. The screen goes from 0 to 127 across and 0 to 63 down. - Shapes: Add
display.drawRect(0, 0, 128, 64, SSD1306_WHITE);right abovedisplay.display();to draw a box around the edge of the screen.
Find the heading that matches what you see, then follow the steps in order.
"The screen is still blank"- Look at LED1 on the board (the rightmost one). If LED1 is on, the board couldn't find the OLED. The code is written to turn LED1 on when that happens.
- Upload the I2C scan code from step 2 again and check Serial Monitor.
- If
0x3Cis not in the result, it's a wiring problem. Unplug USB and re-seat the 4 wires one at a time, following the wiring list above. Pay extra attention to whether SDA and SCL are swapped. - If
0x3Cis in the result, the wiring is fine. Check that the linedisplay.begin(SSD1306_SWITCHCAPVCC, 0x3C)still has0x3Cin it, then upload again. (If you leave the address out, the library picks0x3Dfor 128×64 screens and the screen stays dark.)
Some OLED modules use a slightly different address. You only need to change the address in the code.
- In the code window, press Ctrl+F (Cmd+F on macOS) and search for
0x3C. - Change
0x3Cto0x3D. - Click Upload (→) again.
- Make sure Serial Monitor is open. This code waits for Serial Monitor before it starts scanning. If it's already open, press RESET once.
- If it stops at
Scanning I2C..., a wire is usually in the wrong hole. Unplug USB and check that the SDA or SCL wire isn't plugged into GND or VMOD. - If you get to
Donebut don't even see0x6A, remove all 4 OLED wires and scan again. If0x6Ashows up now, the board is fine. Redo the OLED wiring.
I2C is running at the slow default speed (100 kHz).
- Find the line that starts with
Adafruit_SSD1306 display(. - Change it to the line below. The
400000, 400000at the end is the speed.
Adafruit_SSD1306 display(128, 64, &Wire, -1, 400000, 400000);- Upload again.
💡 Many examples call Wire.setClock(400000) separately, but that has no effect with this library on this board. Put the speed in the line above. 400 kHz is the maximum, so bigger numbers won't make it faster."It was working, then the screen went dark"
A jumper wire has most likely wiggled loose.
- Unplug USB.
- Press all 4 wires firmly into place at both ends.
- Plug USB back in and press RESET once.
VCC and GND are swapped.
- Unplug USB right away.
- Let it cool for a few minutes.
- Read the VCC and GND labels on the OLED again, and wire VCC → VMOD and GND → GND as in the wiring list.
- Plug USB back in and start again from the I2C scan in step 2. If
0x3Cshows up, the module survived.
- All the code for this post is above (also attached as
hello_oled.ino). - See also: a more detailed scanner that also prints the pin map, in nu40-face-mirror / tools/i2c_scan
- Official wiki: NU40 DK Arduino IDE Setting guide
We're a small team in Korea building the NU40 DK. I post my hardware builds on Instagram first at @physical_nunu. Our official account is @nucode_official!
- Official wiki: nucode.gitbook.io/nuseries







Comments