Red & Blue Lights

In Computer Science, I made red and blue lights that go in a loop using a Pico Strip. I coded the lights in Thonny using Python and used a for loop to make them alternate continuously. I learned what RGB stands for (Red, Green, Blue) and how to change the values to create different colors. I also learned how to connect and power the Pico Strip correctly. Next time, I’m going to use a Raspberry Pi to create lights for my robotic car.

import time
import board
import neopixel

# Settings
nPix = 20               # number of led's in the strip
ledPin = board.GP0      # Pin on the RPi Pico (most likely GP0, GP15, or GP27)

pixels = neopixel.NeoPixel(ledPin, nPix)

def lightUp(n=20, color=(0,0,200)):
    for i in range(n):
        pixels[i] = color
        time.sleep(0.1)

# function call
for i in range(10):
    lightUp()
    lightUp(n=20, color=(250,0,0))

Github – Physics/Red & Blue Lights at main · GavinPalatt/Physics

Leave a Reply