# Pico Display Pack 2.8" - micropyton firmware

**URL:** <https://forums.pimoroni.com/t/pico-display-pack-2-8-micropyton-firmware/27005>\
**Category:** Support\
**Created:** [January 4, 2025, 7:23pm UTC](https://forums.pimoroni.com/t/pico-display-pack-2-8-micropyton-firmware/27005 "2025-01-04T19:23:44Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Curt](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/curt/32/10148_2.png) [@Curt](https://forums.pimoroni.com/u/Curt)\
**Post date:** [January 4, 2025, 7:23pm UTC](https://forums.pimoroni.com/t/pico-display-pack-2-8-micropyton-firmware/27005/1 "2025-01-04T19:23:44Z")

</div>

I’m setting up a generic display interface on a Pico 2 W. The display and switches are working but I can’t figure out how to control the LED. Is there any documentation on the LED interface? The LED pins may have changed on the pico 2 w as the switch pins were not the same as the pico 1.

Thanks for the help,  
Curt

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [January 4, 2025, 9:20pm UTC](https://forums.pimoroni.com/t/pico-display-pack-2-8-micropyton-firmware/27005/2 "2025-01-04T21:20:44Z")

</div>

It’s easy to miss, but it is mentioned on the product page.  
Note that the RGB LED is hooked up to different pins on 2.8" (26, 27 and 28) so you may need to adjust for this in your code.  
EDIT: There is also a link to the schematic, which should really help you out.  
What Pico is attached has no bearing on the pins used. The Display pack dictates what pins are used.

---

<div class="post-metadata">

**Author:** ![Curt](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/curt/32/10148_2.png) [@Curt](https://forums.pimoroni.com/u/Curt)\
**Post date:** [January 6, 2025, 7:44pm UTC](https://forums.pimoroni.com/t/pico-display-pack-2-8-micropyton-firmware/27005/3 "2025-01-06T19:44:46Z")

</div>

Thanks for the quick reply. I looked at the schematic but it doesn’t show how to use the pins to set the LED color. I’m not a hardware guy so I might be missing something. Couldn’t find any coding examples.

Curt

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [January 6, 2025, 8:18pm UTC](https://forums.pimoroni.com/t/pico-display-pack-2-8-micropyton-firmware/27005/4 "2025-01-06T20:18:23Z")

</div>

That I can help with as I like to turn them off if I’m not using them. I’ll also throw in some button code just for fun. =)  
EDIT: Let me know if the button code acts up, I seem to remember having issues with a PICO 2?

```auto
from pimoroni import RGBLED, Button
led = RGBLED(26, 27, 28)
led.set_rgb(0, 0, 0)

button_a = Button(12)
button_b = Button(13)
button_x = Button(14)
button_y = Button(15)

while True:

    if button_a.is_pressed:
        led.set_rgb(255, 0, 0) 
                
    if button_b.is_pressed:
        led.set_rgb(0, 255, 0)

    if button_x.is_pressed:
        led.set_rgb(0, 0, 0) 
                
    if button_y.is_pressed:
        led.set_rgb(0, 0, 255)

```

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [January 6, 2025, 8:26pm UTC](https://forums.pimoroni.com/t/pico-display-pack-2-8-micropyton-firmware/27005/5 "2025-01-06T20:26:39Z")

</div>

Just plugged in a Pico 2 / Display Pack 2 setup and found this in my main.py. You already have the buttons working, but I thought I’d post it for anybody else that might read this thread. ;)

```auto
button_a = Pin(12, Pin.IN, Pin.PULL_UP)
button_b = Pin(13, Pin.IN, Pin.PULL_UP)
button_x = Pin(14, Pin.IN, Pin.PULL_UP)
button_y = Pin(15, Pin.IN, Pin.PULL_UP)

while True:
    
    if button_a.value() == 0:
        led.set_rgb(255, 0, 0)
    elif button_b.value() == 0:
        led.set_rgb(0, 255, 0)
    elif button_x.value() == 0:
        led.set_rgb(0, 0, 0)
    elif button_y.value() == 0:
        led.set_rgb(0, 0, 255)

```

---

<div class="post-metadata">

**Author:** ![Curt](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/curt/32/10148_2.png) [@Curt](https://forums.pimoroni.com/u/Curt)\
**Post date:** [January 6, 2025, 8:48pm UTC](https://forums.pimoroni.com/t/pico-display-pack-2-8-micropyton-firmware/27005/6 "2025-01-06T20:48:22Z")

</div>

OK - we’re getting close. I am not using Pimoroni firmware. What does ‘led.set\_rgb (…)’ do to change the color output?

Also in order to get the pins to match the display labels I have to use these settings:

```auto
SWA_PIN = const (15)
SWB_PIN = const (13)
SWX_PIN = const (14)
SWY_PIN = const (12)

```

Curt

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [January 6, 2025, 9:08pm UTC](https://forums.pimoroni.com/t/pico-display-pack-2-8-micropyton-firmware/27005/7 "2025-01-06T21:08:06Z")

</div>

The way it works is, led.set\_rgb (red, green, blue). 0 is off and 255 is full bright.  
led.set\_rgb (255, 255, 0) is yellow for example.  
led.set\_rgb (255, 255, 255) is white.  
([rgb color values for led - Search Videos](https://www.bing.com/videos/riverview/relatedvideo?&q=rgb+color+values+for+led&&mid=89B62E9253147B65885D89B62E9253147B65885D&&FORM=VRDGAR)

---

<div class="post-metadata">

**Author:** ![Curt](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/curt/32/10148_2.png) [@Curt](https://forums.pimoroni.com/u/Curt)\
**Post date:** [January 6, 2025, 10:07pm UTC](https://forums.pimoroni.com/t/pico-display-pack-2-8-micropyton-firmware/27005/8 "2025-01-06T22:07:12Z")

</div>

Here is what I was looking for:

```auto
from time import sleep
from machine import Pin, PWM

PIN_RED = const (27)
PIN_GREEN = const (28)
PIN_BLUE = const (26)
FREQ = const (100)

pin_red = PWM (Pin (PIN_RED), freq = FREQ)
pin_green = PWM (Pin (PIN_GREEN), freq = FREQ)
pin_blue = PWM (Pin (PIN_BLUE), freq = FREQ)

def set_rgb (r, g, b) :
    pin_red.duty_u16 (int (r * 65535 / 255)) # RED: 
    pin_green.duty_u16 (int (g * 65535 / 255)) # GREEN:
    pin_blue.duty_u16 (int (b * 65535 / 255)) # BLUE:

print ("red")
set_rgb (255, 0, 0)
sleep (5)

print ("green")
set_rgb (0, 255, 0)
sleep (5)

print ("blue")
set_rgb (0, 0, 255)

```

As with the buttons, the pins don’t match the schematic.

Colors look kind of weird but that may be the nature of an RGB LED.

Curt

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [January 7, 2025, 8:46am UTC](https://forums.pimoroni.com/t/pico-display-pack-2-8-micropyton-firmware/27005/9 "2025-01-07T08:46:05Z")

</div>

Looking at the schematic,  
SWA is GP12 physical pin 16  
SWB is GP13 physical pin 17  
SWX is GP14 physical pin 19  
SWY is GP15 physical pin 20

Which is what I used above. I just double checked my setup and the buttons are doing what I programed them to do on a version 2 Display Pack. I’ll hunt up my version 2.8 and check that one also.

LED R is GP28 physical pin 31  
LED G is GP27 physical pin 32  
LED B is GP26 physical pin 34

I think you have yours mixed up?  
PIN\_RED = const (27)  
PIN\_GREEN = const (28)  
PIN\_BLUE = const (26)

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [January 7, 2025, 9:01am UTC](https://forums.pimoroni.com/t/pico-display-pack-2-8-micropyton-firmware/27005/10 "2025-01-07T09:01:41Z")

</div>

This my sort of test code. My buttons are working correctly and my LED is showing the correct colors. Display Pack 2.8 on a Pico 2.

```auto
import time
import random
from picographics import PicoGraphics, DISPLAY_PICO_DISPLAY_2, PEN_P8
from pimoroni import RGBLED, Button

display = PicoGraphics(display=DISPLAY_PICO_DISPLAY_2, pen_type=PEN_P8)
display.set_backlight(1.0)

WIDTH, HEIGHT = display.get_bounds()

led = RGBLED(26, 27, 28)
led.set_rgb(0, 0, 0)

from machine import Pin

button_a = Pin(12, Pin.IN, Pin.PULL_UP)
button_b = Pin(13, Pin.IN, Pin.PULL_UP)
button_x = Pin(14, Pin.IN, Pin.PULL_UP)
button_y = Pin(15, Pin.IN, Pin.PULL_UP)

# We're creating 100 balls with their own individual colour and 1 BG colour
# for a total of 101 colours, which will all fit in the custom 256 entry palette!

class Ball:
    def __init__ (self, x, y, r, dx, dy, pen):
        self.x = x
        self.y = y
        self.r = r
        self.dx = dx
        self.dy = dy
        self.pen = pen

# initialise shapes
balls = []
for i in range(0, 100):
    r = random.randint(0, 10) + 3
    balls.append(
        Ball(
            random.randint(r, r + (WIDTH - 2 * r)),
            random.randint(r, r + (HEIGHT - 2 * r)),
            r,
            (14 - r) / 2,
            (14 - r) / 2,
            display.create_pen(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)),
        )
    )

BG = display.create_pen(40, 40, 40)

while True:
    
    if button_a.value() == 0:
        led.set_rgb(255, 0, 0)
    elif button_b.value() == 0:
        led.set_rgb(0, 255, 0)
    elif button_x.value() == 0:
        led.set_rgb(0, 0, 0)
    elif button_y.value() == 0:
        led.set_rgb(0, 0, 255)
    else:
        display.set_pen(BG)
        display.clear()        
    
        for ball in balls:
            ball.x += ball.dx
            ball.y += ball.dy

            xmax = WIDTH - ball.r
            xmin = ball.r
            ymax = HEIGHT - ball.r
            ymin = ball.r

            if ball.x < xmin or ball.x > xmax:
                ball.dx *= -1

            if ball.y < ymin or ball.y > ymax:
                ball.dy *= -1

            display.set_pen(ball.pen)
            display.circle(int(ball.x), int(ball.y), int(ball.r))

        display.update()
        time.sleep(0.01)

```

---

<div class="post-metadata">

**Author:** ![Curt](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/curt/32/10148_2.png) [@Curt](https://forums.pimoroni.com/u/Curt)\
**Post date:** [January 7, 2025, 4:31pm UTC](https://forums.pimoroni.com/t/pico-display-pack-2-8-micropyton-firmware/27005/11 "2025-01-07T16:31:08Z")

</div>

Looks like both our implementations work. Pimoroni may be fiddling with the pin numbers to maintain backward or cross compatibly.

Good discussion,  
Curt

---

<div class="post-metadata">

**Author:** ![Curt](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/curt/32/10148_2.png) [@Curt](https://forums.pimoroni.com/u/Curt)\
**Post date:** [January 11, 2025, 10:36pm UTC](https://forums.pimoroni.com/t/pico-display-pack-2-8-micropyton-firmware/27005/12 "2025-01-11T22:36:50Z")

</div>

In case you are curious, here is the code I used to interface to the Display Pack:

```auto
import display_modules.st7789py as st7789

SPI_ID = const (0)
BAUDRATE = const (40000000)
SCK_PIN = const (18)
MOSI_PIN = const (19)
MISO_PIN = None
RESET_PIN = const (11)
CS_PIN = const (17)
DC_PIN = const (16)
BACKLIGHT_PIN = const (20)
HEIGHT = const (320)
WIDTH = const (240)

st_display = st7789.ST7789 (
        SPI (SPI_ID ,
             baudrate = BAUDRATE ,
             sck = SCK_PIN ,
             mosi = MOSI_PIN ,
             miso = MISO_PIN) ,
        WIDTH ,
        HEIGHT ,
        reset = Pin (RESET_PIN, Pin.OUT) ,
        cs = Pin (CS_PIN, Pin.OUT) ,
        dc = Pin (DC_PIN, Pin.OUT) ,
        backlight = Pin (BACKLIGHT_PIN, Pin.OUT) ,
        rotation = ROTATION)

```

[Link to st7789 driver](https://github.com/russhughes/st7789py_mpy/blob/master/lib/st7789py.py)

Demo output:

 ![demopim](https://us1.discourse-cdn.com/flex016/uploads/pimoroni/original/2X/9/9b445693c11184eed27f0312b7defbaf1864245a.jpeg)

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [January 12, 2025, 9:46am UTC](https://forums.pimoroni.com/t/pico-display-pack-2-8-micropyton-firmware/27005/13 "2025-01-12T09:46:35Z")

</div>

It is an interesting conversation. You doing it with plain old vanilla Micro Python does make it interesting. There are a few others here that like doing it that way when possible. I’m too lazy and impatient to go that route. ;)
