pimoroni-pico/micropython/examples/plasma_2040/rgb-led-and-buttons.py

22 lines
576 B
Python

import time
# Import pin constants from plasma
from plasma import PIN_LED_R, PIN_LED_G, PIN_LED_B, PIN_BUTTON_A, PIN_BUTTON_B
# Import helpers for RGB LEDs and Buttons
from pimoroni import RGBLED, Button
led = RGBLED(PIN_LED_R, PIN_LED_G, PIN_LED_B)
led.set_rgb(255, 0, 0)
button_a = Button(PIN_BUTTON_A)
button_b = Button(PIN_BUTTON_B)
while True:
if button_a.read():
print("Pressed A - {}".format(time.ticks_ms()))
led.set_rgb(0, 255, 0)
if button_b.read():
print("Pressed B - {}".format(time.ticks_ms()))
led.set_rgb(0, 0, 255)