Skip to content

Instantly share code, notes, and snippets.

@BenjaminSantiago
BenjaminSantiago / CPX__blinkyRED__withCOMMENTS.py
Created September 15, 2021 17:23
CPX Red LED blinky light example with comments
"""
This is a multiline comment, you use it to
describe what the program does, or a more
involved piece of code.
You just type 3 quotation marks to start a
multiline comment "block" and then another 3
quotation mark to end the block.
This code turns the red blinky LED (labeled D13)
@BenjaminSantiago
BenjaminSantiago / CPX__neopixelFILL.py
Last active September 22, 2021 06:08
Turning on all neopixels on the CPX
"""
In this example we will turn on all the neopixels in the CPX
"""
# --------------------------
import time
from adafruit_circuitplayground import cp
# --------------------------
# --------------------------
@BenjaminSantiago
BenjaminSantiago / CPX__challenge__GLOW.py
Last active September 22, 2021 06:57
make it so the neopixels "glow"
from adafruit_circuitplayground import cp
import time
cp.pixels.brightness = 1
sleep_time = 0.001
while True:
for c in range(0, 256):
cp.pixels.fill((c, 0, c))
@BenjaminSantiago
BenjaminSantiago / CPX__neopixelINDIVIDUAL.py
Last active September 22, 2021 06:15
Update neopixels individually
"""
In this example we will light up each neopixel individually
"""
# --------------------------
from adafruit_circuitplayground import cp
# --------------------------
# --------------------------
while True:
@BenjaminSantiago
BenjaminSantiago / CPX__neopixelsINDIVIDUAL__ALL.py
Created September 22, 2021 06:16
light up each neopixel in sequence
"""
In this example we will light up each neopixel individually
"""
# --------------------------
import time
from adafruit_circuitplayground import cp
# --------------------------
# --------------------------
@BenjaminSantiago
BenjaminSantiago / CPX__neopixelsINDIVIDUAL__for.py
Created September 22, 2021 06:20
Use a for loop to light up each neopixel in sequence
"""
In this example we will light up each neopixel individually
except this time...use a for loop
"""
# --------------------------
import time
from adafruit_circuitplayground import cp
# --------------------------
@BenjaminSantiago
BenjaminSantiago / CPX__buttonA__IF.py
Last active September 22, 2021 06:32
Use button A to light up the neopixels
"""
Here, we'll use the button to light up all the neopixels
"""
# --------------------------
from adafruit_circuitplayground import cp
# --------------------------
# --------------------------
while True:
@BenjaminSantiago
BenjaminSantiago / CPX__buttonA__ELSE.py
Created September 22, 2021 06:28
make it so that pressing the button turns the lights off and letting go turns it off.
"""
Here, we'll use the button to light up all the neopixels
"""
# --------------------------
from adafruit_circuitplayground import cp
# --------------------------
# --------------------------
while True:
@BenjaminSantiago
BenjaminSantiago / CPX__switch.py
Created September 22, 2021 06:34
use the sliding switch on the CPX
"""
use the switch to turn on the neopixels
"""
# --------------------------
from adafruit_circuitplayground import cp
# --------------------------
# --------------------------
while True:
@BenjaminSantiago
BenjaminSantiago / CPX__challenge__sequence.py
Last active September 22, 2021 07:03
make it so the neopixels light up and turn off in a sequence
"""
make it so the pixels turn on and off in sequence
"""
# our imports
# -------------------------------------------
from adafruit_circuitplayground import cp
import time
# -------------------------------------------