Introduction: Butterfly CPX

We made a butterfly that is on top of a lit up CPX board. The purpose of this is to spin and flash different patterns of light.

Supplies

-CPX 3-D printed base/holder

-3-D printed butterfly

-servo motor

-cpx board with wire to connect to computer

-battery

-wires

Step 1: Print

Print 3-D butterfly and CPX holders.

Step 2: Code

Create the code to allow the CPX board to light up with specific patterns and functions. Use python for this step.


from adafruit_circuitplayground import cp

# SPDX-FileCopyrightText: 2019 Anne Barela for Adafruit Industries

#

# SPDX-License-Identifier: MIT

"""CircuitPython Essentials Servo continuous rotation servo example"""

import time

import board

import pwmio

from adafruit_motor import servo

# create a PWMOut object on Pin A2.

pwm = pwmio.PWMOut(board.A2, frequency=50)

# Create a servo object, my_servo.

my_servo = servo.ContinuousServo(pwm)

while True:

    cp.pixels[9] = (255, 0, 0)  # Red

    cp.pixels[8] = (255, 0, 0)  # Red

    cp.pixels[7] = (255, 127, 0) # Orange

    cp.pixels[6] = (255, 255, 0) # Yellow

    cp.pixels[5] = (255, 255, 0) # Yellow (repeated)

    cp.pixels[4] = (0, 255, 0)  # Green

    cp.pixels[3] = (0, 255, 0)  # Green (repeated)

    cp.pixels[2] = (0, 0, 255)  # Blue

    cp.pixels[1] = (0, 0, 255)  # Blue (repeated)

    cp.pixels[0] = (127, 0, 255)  # Purple



    if cp.button_b:

        cp.play_tone(1000, .5)

        my_servo.throttle = 1.0

        time.sleep(.5)

        my_servo.throttle = -1.0

        time.sleep(.5)

    else:

        my_servo.throttle = 0.0



Step 3: Wiring

Glue the servo motor to the bottom of the CPX holder. Solder the red wire to VOUT and A2 to orange. Then attach brown to the ground.

Step 4: Assemble Butterfly

Attach the wings to the body of the butterfly. Then, attach the whole butterfly onto the top of the CPX board.