RGB Lights
The StudioBot has 4 RGB lights under the display. We can use these lights to show colours and signal output to the user.
The following code will set the light colours to red, green, blue with 2 seconds between each change.
import time
import board
import neopixel
pixel_pin = board.NEOPIXEL
num_pixels = 4
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.3, auto_write=False)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
pixels.fill(RED)
pixels.show()
time.sleep(2)
pixels.fill(GREEN)
pixels.show()
time.sleep(2)
pixels.fill(BLUE)
pixels.show()
To set a single pixel color
The following code will show how to make the RGB lights swap colours after a given delay.
Last updated