RGB working for Android 16: Tutorial

Pironman5 RGB on KonstaKANG Android 16 (Working Setup Guide)

This guide documents the exact steps that successfully got the SunFounder Pironman5 RGB LEDs working under KonstaKANG Android 16 on a Raspberry Pi 5.


Hardware / Software Used

  • Raspberry Pi 5

  • SunFounder Pironman5 case

  • KonstaKANG Android 16

  • Root access via Magisk

  • Termux

  • SPI enabled


What Was Learned

The Pironman5 RGB LEDs:

  • Use WS2812 LEDs

  • Use SPI communication

  • Use /dev/spidev0.0

  • Use Adafruit NeoPixel SPI library

  • Require the sunfounder-pironman5.dtbo overlay

The official Pironman5 software uses:

  • adafruit-circuitpython-neopixel-spi

  • NeoPixel_SPI

  • GRB color order

  • 4 LEDs


Step 1 — Install Required Packages in Termux

Open Termux and install:

pkg update
pkg install python clang
pip install spidev
pip install adafruit-blinka
pip install adafruit-circuitpython-neopixel-spi
pip install "setuptools<70" --force-reinstall

The setuptools downgrade is important because newer setuptools versions remove pkg_resources, which Adafruit libraries expect.

Verify:

python -c "import pkg_resources; print('pkg_resources works')"


Step 2 — Verify SPI Devices Exist

Run:

su
ls -l /dev/spidev*

Working output included:

/dev/spidev0.0
/dev/spidev0.1
/dev/spidev10.0

The working RGB configuration ultimately used:

/dev/spidev0.0


Step 3 — Enable Pironman Overlay

Verify overlay exists:

ls /boot/overlays | grep sunfounder

Expected:

sunfounder-pironman5.dtbo

Edit:

nano /boot/config.txt

Add:

dtoverlay=sunfounder-pironman5
dtparam=spi=on

Reboot:

reboot


Step 4 — Create Working RGB Script

Create:

nano /data/data/com.termux/files/home/pironman_rgb.py

Paste:

import time
import spidev
import neopixel_spi as neopixel

class AndroidSPI:
    def __init__(self):
        self.spi = spidev.SpiDev()
        self.spi.open(0,0)
        self.spi.max_speed_hz = 6400000
        self.spi.mode = 0
        self.locked = False

    def try_lock(self):
        self.locked = True
        return True

    def unlock(self):
        self.locked = False

    def configure(self, baudrate=6400000, phase=0, polarity=0, bits=8):
        self.spi.max_speed_hz = baudrate
        self.spi.mode = (polarity << 1) | phase

    def write(self, buf, start=0, end=None):
        if end is None:
            end = len(buf)
        self.spi.writebytes(list(buf[start:end]))

pixels = neopixel.NeoPixel_SPI(
    AndroidSPI(),
    4,
    pixel_order=neopixel.GRB,
    auto_write=False,
    brightness=0.15
)

pixels.fill((0,255,0))
pixels.show()

print("RGB active")

while True:
    time.sleep(60)


Step 5 — Run RGB Script

Run as a one-line command:

su -c "chmod 666 /dev/spidev0.0 && cd /data/data/com.termux/files/home && /data/data/com.termux/files/usr/bin/python pironman_rgb.py"

If successful, LEDs should turn on.


Step 6 — Change RGB Color

Edit this line:

pixels.fill((0,255,0))

Examples:

Green:

(0,255,0)

Red:

(255,0,0)

Blue:

(0,0,255)

Purple:

(255,0,255)

White:

(255,255,255)

Dark Green:

(0,80,0)


Step 7 — Adjust Brightness

Brightness is controlled here:

brightness=0.15

Examples:

Very dim:

brightness=0.05

Dim:

brightness=0.1

Medium:

brightness=0.3

Bright:

brightness=0.6

Maximum:

brightness=1.0


Step 8 — Create RGB OFF Script

Create:

nano /data/data/com.termux/files/home/rgb_off.py

Paste:

import spidev
import neopixel_spi as neopixel

class AndroidSPI:
    def __init__(self):
        self.spi = spidev.SpiDev()
        self.spi.open(0,0)
        self.spi.max_speed_hz = 6400000
        self.spi.mode = 0
        self.locked = False

    def try_lock(self):
        self.locked = True
        return True

    def unlock(self):
        self.locked = False

    def configure(self, baudrate=6400000, phase=0, polarity=0, bits=8):
        self.spi.max_speed_hz = baudrate
        self.spi.mode = (polarity << 1) | phase

    def write(self, buf, start=0, end=None):
        if end is None:
            end = len(buf)
        self.spi.writebytes(list(buf[start:end]))

pixels = neopixel.NeoPixel_SPI(
    AndroidSPI(),
    4,
    pixel_order=neopixel.GRB,
    auto_write=False
)

pixels.fill((0,0,0))
pixels.show()

print("RGB OFF")


Step 9 — Turn RGB OFF

Kill RGB process:

su -c "pkill -f pironman_rgb.py"

Then:

su -c "chmod 666 /dev/spidev0.0 && cd /data/data/com.termux/files/home && /data/data/com.termux/files/usr/bin/python rgb_off.py"


Optional — Run RGB Automatically At Boot

Create boot script:

su
mkdir -p /data/adb/service.d

Create:

/data/adb/service.d/pironman_rgb.sh

Contents:

#!/system/bin/sh

sleep 30

chmod 666 /dev/spidev0.0

/data/data/com.termux/files/usr/bin/python /data/data/com.termux/files/home/pironman_rgb.py &

Make executable:

chmod 755 /data/adb/service.d/pironman_rgb.sh

Reboot.


Notes

  • LEDs may remain on after shutdown because WS2812 LEDs remember their last state.

  • Sudden crashes/power loss may leave LEDs frozen on.

  • Android board detection for Adafruit Blinka does not work normally on KonstaKANG Android, so a custom SPI wrapper class was required.

  • /dev/spidev10.0 did not work for RGB control.

  • The working SPI bus was:

/dev/spidev0.0


Final Result

Pironman5 RGB LEDs successfully working on KonstaKANG Android 16 using:

I now have RGB lights and OLED screen working with android 16. It was not easy and quite the headache but here you go. My other tutorial for making the OLED screen work with android exists on this forum also. Good luck.

Thank you very much for sharing your experience and the tutorial. We truly appreciate the time and effort.

Your contributions will certainly help other users in the community who are attempting similar setups. We are glad to hear that you were able to overcome the difficulties.