Basic LCD + Button Control Guide

W55MH32L-ADK

The W55MH32L-ADK features an on-board ST7789 color LCD display and on-board push buttons. This guide covers their pin assignments, hardware setup, and how to program them in MicroPython.

ADK-Buy Buy now

Under this page, you will find the code for using the the ST7789 and On-Board buttons of the board. If you need a detailed guide, please visit W55MH32L-ADK Reference.


Features

  • On-Board ST7789 Color LCD: Driven over SPI (240x320 resolution) with dedicated control pins for reset, data/command, chip select, and backlight.

  • On-Board Tactile Buttons: Direct MCU GPIO inputs configured with pull-ups for responsive local control.

  • Ready-to-Use Prototyping Layout: All display and button signals are wired directly on the Application Kit board.


Pinout & Hardware Mapping

On-Board Buttons

The sample code maps each button to its corresponding MCU pin using internal pull-ups (Pin.PULL_UP), reading 0 when pressed (active-low):

Button

MCU Pin

Mode / Pull

Pressed State

UP

PA8

Pin.IN, Pin.PULL_UP

0 (Low)

DOWN

PC7

Pin.IN, Pin.PULL_UP

0 (Low)

LEFT

PC6

Pin.IN, Pin.PULL_UP

0 (Low)

RIGHT

PG8

Pin.IN, Pin.PULL_UP

0 (Low)

A

PF13

Pin.IN, Pin.PULL_UP

0 (Low)

B

PF11

Pin.IN, Pin.PULL_UP

0 (Low)

ST7789 Display

Display Signal

MCU Pin / Bus

Role

SPI Bus

SPI(1) (10 MHz, polarity=0, phase=0)

Serial display data transfer

Backlight (BL)

PB1

Output (1 to enable backlight)

Reset (RST)

PC5

Display hardware reset

Data/Command (DC)

PB0

Selects command vs. pixel data

Chip Select (CS)

PC4

SPI slave select


Platforms Supported

MicroPython

mpy-logo


Instructions

  • W55MH32L-ADK

  • USB Type-C Cable

  1. Connect a USB Type-C cable from the WIZ-LINK Port on the W55MH32L-ADK to your PC.

  2. Ensure the required display driver files (st7789py and vga2_8x8) are available on your MicroPython device.


Sample Code Demo

Software

We will be using Thonny IDE to run the code.

  1. Open Thonny IDE on your PC.

  2. Select the correct COM port for your board.

  3. Set the interpreter to MicroPython (generic).

Refer to the WIZnet documentation page for more detailed instructions in the Basic Setup section.

MicroPython

import time
import machine
import st7789py as st7789
import vga2_8x8

# --- Display Setup ---
bl_pin = machine.Pin("PB1", machine.Pin.OUT)
bl_pin.value(1)  # Set to 0 if your backlight is active-low

rst_pin = machine.Pin("PC5", machine.Pin.OUT)
dc_pin = machine.Pin("PB0", machine.Pin.OUT)
cs_pin = machine.Pin("PC4", machine.Pin.OUT)

spi = machine.SPI(1, baudrate=10_000_000, polarity=0, phase=0)

display = st7789.ST7789(
    spi,
    240,
    320,
    reset=rst_pin,
    dc=dc_pin,
    cs=cs_pin,
    backlight=bl_pin,
    rotation=0,
)
display.inversion_mode(True)


def show_message(title, detail="", bg_color=st7789.BLACK, fg_color=st7789.WHITE):
    display.fill(bg_color)
    display.text(vga2_8x8, title, 16, 40, fg_color, bg_color)
    if detail:
        display.text(vga2_8x8, detail, 16, 60, fg_color, bg_color)


# --- Button Setup ---
# Assumes active-low buttons (pin reads 0 when pressed) using internal pull-ups.
# If your buttons connect to 3.3V instead, change Pin.PULL_UP to Pin.PULL_DOWN
# and invert the pressed check (pin.value() == 1).
buttons = {
    "UP": {
        "pin": machine.Pin("PA8", machine.Pin.IN, machine.Pin.PULL_UP),
        "title": "UP PRESSED",
        "detail": "Moving UP...",
        "bg": st7789.BLUE,
        "fg": st7789.WHITE,
    },
    "DOWN": {
        "pin": machine.Pin("PC7", machine.Pin.IN, machine.Pin.PULL_UP),
        "title": "DOWN PRESSED",
        "detail": "Moving DOWN...",
        "bg": st7789.GREEN,
        "fg": st7789.BLACK,
    },
    "LEFT": {
        "pin": machine.Pin("PC6", machine.Pin.IN, machine.Pin.PULL_UP),
        "title": "LEFT PRESSED",
        "detail": "Moving LEFT...",
        "bg": st7789.YELLOW,
        "fg": st7789.BLACK,
    },
    "RIGHT": {
        "pin": machine.Pin("PG8", machine.Pin.IN, machine.Pin.PULL_UP),
        "title": "RIGHT PRESSED",
        "detail": "Moving RIGHT...",
        "bg": st7789.MAGENTA,
        "fg": st7789.WHITE,
    },
    "A": {
        "pin": machine.Pin("PF13", machine.Pin.IN, machine.Pin.PULL_UP),
        "title": "BUTTON A",
        "detail": "Action A triggered!",
        "bg": st7789.RED,
        "fg": st7789.WHITE,
    },
    "B": {
        "pin": machine.Pin("PF11", machine.Pin.IN, machine.Pin.PULL_UP),
        "title": "BUTTON B",
        "detail": "Action B triggered!",
        "bg": st7789.WHITE,
        "fg": st7789.BLACK,
    },
}

# --- Main Loop ---
show_message("READY", "Press any button...")
last_pressed = None
last_press_time = 0
debounce_ms = 180

while True:
    now = time.ticks_ms()
    pressed_now = None

    for name, cfg in buttons.items():
        if cfg["pin"].value() == 0:  # Active-low pressed state
            pressed_now = name
            break

    if pressed_now is not None:
        if pressed_now != last_pressed or time.ticks_diff(now, last_press_time) > debounce_ms:
            cfg = buttons[pressed_now]
            show_message(cfg["title"], cfg["detail"], cfg["bg"], cfg["fg"])
            last_pressed = pressed_now
            last_press_time = now
    else:
        # Reset so pressing the same button again immediately registers
        last_pressed = None

    time.sleep_ms(20)

Display and Button Demo

Schematic

Download: W55MH32L-ADK Schematics