Jo highVoltage Harry Potter Lego Quidditch Match

Jo highVoltage brought her lego scene to life using her CPX, a Crickit, a continuous servo, a NeoPixel strip and an external speaker.  This project is coded in CircuitPython.

The video shows how the project was made.

 

Here is the CircuitPython code for this project:

import time
import board
import digitalio
from adafruit_crickit import crickit
import neopixel
import audioio

num_pixels = 30   # Number of pixels driven from Crickit NeoPixel terminal
pixels = neopixel.NeoPixel(board.A1, num_pixels,
brightness=0.3, auto_write=False)
RED = (204, 51, 0)
YELLOW = (255, 255, 102)
GREEN = (10, 204, 10)
GREY = (102, 153, 153)
BROWN = (153, 51, 0)
GOLD = (255, 204, 0)
BLUE = (0, 0, 204)
GRAY = (102, 133, 153)

wave_file = open(“HarryP.wav”, “rb”)
wave = audioio.WaveFile(wave_file)
audio = audioio.AudioOut(board.A0)

buttonA = digitalio.DigitalInOut(board.BUTTON_A)
buttonA.direction = digitalio.Direction.INPUT
buttonA.pull = digitalio.Pull.DOWN

buttonB = digitalio.DigitalInOut(board.BUTTON_B)
buttonB.direction = digitalio.Direction.INPUT
buttonB.pull = digitalio.Pull.DOWN

while True:

if crickit.touch_1.value:
print(“pad one touched”)

audio.play(wave)
pass

if buttonA.value:
print(“Wants to go to T.J. Maxx Josie does.”)
crickit.continuous_servo_2.throttle = 0.07   # Forwards
time.sleep(.5)
pass

if buttonB.value:
print(“Stopped chu hav.”)
crickit.servo_2._pwm_out.duty_cycle = 0
#  crickit.continuous_servo_2.throttle = 0 # Forwards halfspeed
time.sleep(.5)

for i in range(0, 3, 1):
pixels[i] = RED
pixels.show()
time.sleep(0.1)
for i in range(3, 6, 1):
pixels[i] = GOLD
pixels.show()
time.sleep(0.1)
for i in range(6, 9, 1):
pixels[i] = BLUE
pixels.show()
time.sleep(0.1)
for i in range(9, 15, 1):
pixels[i] = GRAY
pixels.show()
time.sleep(0.1)
for i in range(15, 19, 1):
pixels[i] = GOLD
pixels.show()
time.sleep(0.1)
for i in range(19, 23, 1):
pixels[i] = BROWN
pixels.show()
time.sleep(0.1)
for i in range(22, 25, 1):
pixels[i] = GREEN
pixels.show()
time.sleep(0.1)
for i in range(26, 30, 1):
pixels[i] = GREY
pixels.show()
time.sleep(0.1)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s