blink the RGB LED on the PyCubed boards

Use the built-in CircuitPython library called neopixel to operate the red-green-blue (RGB) LED.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/97c7873d-7225-45e6-83ce-4eb686065659/rgb.jpg

⚙ Hardware Needed


📚 External Libraries Needed


None

📑 Code


'''
general blink routine

~~M~~.Holliday 2018
'''

import time
import board
import neopixel

# Initialize an instance of the neopixel class called "RGB"
RGB = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.5, auto_write=False)

######################### MAIN LOOP ##############################
delay = 2 # make bigger to slow down
i = 0 # a counter to increment each loop
while True:
  print(i)
  RGB[0] = (0,255,0) # pure green in Red,Green,Blue format
  time.sleep(delay) 
  RGB[0] = (0,0,0) # turn the NeoPixel off
  time.sleep(delay)
  i += 1

Using the pycubed.py helper library:

from pycubed import cubesat
import time

while True:
	cubesat.RGB = (0,255,0)
	time.sleep(0.5)
	cubesat.RGB = (0,0,0)
	time.sleep(0.5)

↩ Return Home

↩ Return to Resources

↩ Return to Code Examples