pdf-icon

UIFlow Guide

UiFlow1 Blockly

Event

Unit

UiFlow1 Project

Unit RGB LED

Example

Matrix flowing light

from m5stack import *
from m5stack_ui import *
from uiflow import *
import time
import unit

screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0xFFFFFF)
neopixel_0 = unit.get(unit.NEOPIXEL, unit.PORTB, 10)

R = None
G = None
B = None
i = None

import random

while True:
  R = random.randint(0, 255)
  G = random.randint(0, 255)
  B = random.randint(0, 255)
  for i in range(1, 31):
    neopixel_0.setColorFrom(1,i,(R << 16) | (G << 8) | B)
  wait_ms(500)
  for i in range(1, 31):
    neopixel_0.setColorFrom(1, i, 0x000000)
  wait_ms(500)
  wait_ms(2)

API

neopixel_0.setBrightness(20)
  • Set brightness
neopixel_0.setColor(1, 0xff0000)
  • Set color
neopixel_0.setColorAll(0xff0000)
  • Set the color of a specified single LED
neopixel_0.setColorAll(0xff0000)
  • Set the color of all LEDs
neopixel_0.setColorFrom(1, 5, 0xff0000)
  • Set the color of RGB LEDs in a specified range
neopixel_0.setColorFrom(1, 5, 0xff0000)
  • Set the color of RGB LEDs in a specified range
neopixel_0.setColorFrom(1, 5, 0x000000)
  • Set the color of RGB LEDs in a specified range (RGB)
neopixel_0.setColor(1, 0xff0000)
  • Set the color of a specified RGB LED
neopixel_0.setShowLock(True)
  • Set the hexagonal matrix
neopixel_0.setShowLock(True)
  • Set the RGB lights of the hexagonal matrix
neopixel_0.setShowLock(True)
  • Set display lock status
neopixel_0.show()
  • Display RGB LED
On This Page