Introduction: Animated Professor That Talks!

This is a piece of art that when interacted with displays a light animation and talks!

Supplies

1/8 and 1/4 inch birch wood

Laser Cutter

Wires

Adabluefruit CPB

Speaker

Button

LED Light strip

Hot Glue

Cardboard

Battery pack

Tape

Step 1:

Sketch the image you want to engrave and format it in illustrator. Then push project to a laser cutter that will engrave it into 1/8th inch baltic birch.

Step 2:

Tape or glue the LEDs into the whole that were cut for them and wire them into the CPB

Step 3:

Glue the speaker down and wire it correctly to the CPB

Step 4:

Wire the button in and seat it properly into the face of the project

Step 5:

Measure and cut out a stand and attach it with hot glue and measure out a box to enclose eveything in. You can use cardboard or wood.

Step 6:

Code whichever animations and sounds you'd like.

Here is my code:

# import lines needed to play sound files

import board, digitalio, time, neopixel, random

from audiopwmio import PWMAudioOut as AudioOut

from audiocore import WaveFile


# Speaker

speaker = digitalio.DigitalInOut(board.SPEAKER_ENABLE)

speaker.direction = digitalio.Direction.OUTPUT

speaker.value = True

audio = AudioOut(board.AUDIO)


path = "sounds/"

filename="untitled.wav"

# play_sound function - pass in the FULL NAME of file to play

def play_sound(filename, anim):

  with open(path + filename, "rb") as wave_file:

    wave = WaveFile(wave_file)

    audio.play(wave)

    while audio.playing:

      anim.animate()



# Button


# Use Pull.UP for external buttons wired to ground

button = digitalio.DigitalInOut(board.A4) # Wired to pin GP15

button.switch_to_input(pull=digitalio.Pull.UP)


from adafruit_led_animation.animation.blink import Blink

from adafruit_led_animation.animation.colorcycle import ColorCycle

from adafruit_led_animation.animation.chase import Chase

from adafruit_led_animation.animation.comet import Comet

from adafruit_led_animation.animation.pulse import Pulse

from adafruit_led_animation.animation.sparkle import Sparkle

from adafruit_led_animation.animation.sparklepulse import SparklePulse

from adafruit_led_animation.animation.rainbow import Rainbow

from adafruit_led_animation.animation.rainbowchase import RainbowChase

from adafruit_led_animation.sequence import AnimationSequence


from adafruit_led_animation.color import (

  AMBER, # (255, 100, 0)

  AQUA, # (50, 255, 255)

  BLACK, # OFF (0, 0, 0)

  BLUE, # (0, 0, 255)

  CYAN, # (0, 255, 255)

  GOLD, # (255, 222, 30)

  GREEN, # (0, 255, 0)

  JADE, # (0, 255, 40)

  MAGENTA, # (255, 0, 20)

  OLD_LACE, # (253, 245, 230)

  ORANGE, # (255, 40, 0)

  PINK, # (242, 90, 255)

  PURPLE, # (180, 0, 255)

  RED, # (255, 0, 0)

  TEAL, # (0, 255, 120)

  WHITE, # (255, 255, 255)

  YELLOW, # (255, 150, 0)

  RAINBOW, # a list of colors to cycle through

  # RAINBOW is RED, ORANGE, YELLOW, GREEN, BLUE, and PURPLE ((255, 0, 0), (255, 40, 0), (255, 150, 0), (0, 255, 0), (0, 0, 255), (180, 0, 255))

)


pixels_pin = board.NEOPIXEL

pixels_num_of_lights = 10

pixels = neopixel.NeoPixel(pixels_pin, pixels_num_of_lights, brightness=0.5)


strip_pin = board.A1

strip_num_of_lights = int(20)

strip = neopixel.NeoPixel(strip_pin, strip_num_of_lights, brightness=0.5, auto_write=True)


INDIGO = (63, 0, 255)

VIOLET = (127, 0, 255)

OFF = 0, 0, 0

pause = 0.3

mycolors = [

  RED,

  MAGENTA,

  ORANGE,

  YELLOW,

  GREEN,

  JADE,

  BLUE,

  INDIGO,

  VIOLET,

  PURPLE,

  OFF,

]


blink = Blink(pixels, speed=0.5, color=JADE)

blink_strip = Blink(strip, speed=0.5, color=AMBER)


colorcycle = ColorCycle(pixels, 0.1, colors=mycolors)

colorcycle_strip = ColorCycle(strip, 0.1, colors=mycolors)


chase = Chase(pixels, speed=0.1, color=WHITE, size=3, spacing=6)

chase_strip = Chase(strip, speed=0.1, color=WHITE, size=1, spacing=1)


comet = Comet(pixels, speed=0.05, color=RED, tail_length=10, bounce=True)

comet_strip = Comet(

  strip, speed=0.05, color=RED, tail_length=int(strip_num_of_lights / 4), bounce=True

)


pulse = Pulse(pixels, speed=0.05, color=AMBER, period=2)

pulse_strip = Pulse(strip, speed=0.05, color=BLUE, period=2)


sparkle = Sparkle(pixels, speed=0.05, color=PURPLE)

sparkle_strip = Sparkle(strip, speed=0.05, color=PURPLE)


sparkle_pulse = SparklePulse(pixels, speed=0.05, period=5, color=BLUE)

sparkle_pulse_strip = SparklePulse(strip, speed=0.05, period=5, color=BLUE)


rainbow = Rainbow(pixels, speed=0.05, period=2)

rainbow_strip = Rainbow(strip, speed=0.05, period=2)


rainbow_chase = RainbowChase(pixels, speed=0.01, size=5, spacing=0, step=8)

rainbow_chase_strip = RainbowChase(strip, speed=0.01, size=5, spacing=0, step=8)


animations = AnimationSequence(

  blink,

  colorcycle,

  chase,

  comet,

  pulse,

  sparkle,

  sparkle_pulse,

  rainbow,

  rainbow_chase,

  advance_interval=5,

  auto_clear=True,

)


animations_strip = AnimationSequence(

  blink_strip,

  colorcycle_strip,

  chase_strip,

  comet_strip,

  pulse_strip,

  sparkle_strip,

  sparkle_pulse_strip,

  rainbow_strip,

  rainbow_chase_strip,

  advance_interval=5,

  auto_clear=True,

)


while True:

  if button.value == False:

    print("Button pressed!")

    q = random.randint(0,6)

    print(q)

    if q == 0:

      play_sound("untitled.wav", rainbow_strip)

    elif q == 1:

      play_sound("untitled.wav", chase_strip)

    elif q == 2:

      play_sound("letscode.wav", sparkle_strip)

    elif q == 3:

      play_sound("letscode.wav", comet_strip)

    elif q == 4:

      play_sound("keepatit.wav", pulse_strip)

    elif q == 5:

      play_sound("keepatit.wav", colorcycle_strip)

    elif q == 6:

      #for i in range(0,20,1):

       #  strip.show()

      #  w = int(random.randint(0,255))

      #  print(w)

      #  e = int(random.randint(0,255))

      #  print(e)

      #  r = int(random.randint(0,255))

      #  print(r)

      #  strip[i] =((w,e,r))

      #  time.sleep(0.05)

      play_sound("untitled.wav", rainbow_chase_strip)

    strip.fill(BLACK)

    strip.show()

  #else:

    #strip.fill((0,0,0))

    #pixels.fill((0,0,0))

    # blink_strip.animate()

    # colorcycle.animate()

    # colorcycle_strip.animate()

    # chase.animate()

    # chase_strip.animate()

    # comet.animate()

    # comet_strip.animate()

    # pulse.animate()

    # pulse_strip.animate()

    # sparkle.animate()

    # sparkle_strip.animate()

    # sparkle_pulse.animate()

    # sparkle_pulse_strip.animate()

    # rainbow.animate()

    # rainbow_strip.animate()

    # rainbow_chase.animate()

    # rainbow_chase_strip.animate()

    # animations.animate()