You can code this project in either Microsoft MakeCode or CircuitPython, both are super easy.


Time to tell the bot what to do in Microsoft MakeCode. If you are new to using MakeCode and Circuit Playground Express, see this guide to demonstrate how to get things going.

The program for the bubble machine only takes a few code blocks:

When the boards power on, on start is run. The DC motor with the fan is set to 100% speed. Feel free to adjust this if it is too strong for your setup and solution - a lower value might prevent bubbles popping immediately when the wand comes up.

The forever loop lifts the wand out of the solution (angle 30 degrees), waits two seconds, then dips it down again waiting 2/5ths of a second in the solution before repeating.


The CircuitPython code is very similar to the MakeCode. Motor 2 for the fan is turned on and the servo is told to move up and down at timed intervals. I had to adjust one angle from 165 in MakeCode to 145 in CircuitPython to get the movement the same as the MakeCode.

# SPDX-FileCopyrightText: 2018 Anne Barela for Adafruit Industries
# SPDX-License-Identifier: MIT

# CircuitPython 3.0 CRICKIT dMake It Bubble
import time
from adafruit_crickit import crickit

motor_2 = crickit.dc_motor_2
motor_2.throttle = 1  # full speed forward

while True:
    print("servo up")
    crickit.servo_1.angle = 30
    print("servo down")
    crickit.servo_1.angle = 145

Possible Modifications to the Code

If the servo angles do not correspond to your setup, they should be adjusted accordingly. It might be easier to remove the servo horn, twist it to the area you want the wand to move and resecure it if the horn screw is accessible.

The pauses between actions are adjustable to your setup. You may need more than 2 seconds to have the fan blow all of the bubble fluid off the wand. If it is blowing bubbles at too fast a rate, adjust the 400 milliseconds up.

If the fan is blowing too hard, you can do two things:

  1. Adjust the fan further back from the wand
  2. Adjust the fan speed in the sketch to be lower

The fan does not need to be at 100% (CircuitPython 1). Probably you do not want it much below 75% (CircuitPython 0.75), the factor here is the viscosity/thickness of the bubble solution. If it is real thick, more air will be needed.

This guide was first published on Aug 22, 2018. It was last updated on Nov 29, 2023.

This page (Code) was last updated on Nov 29, 2023.

Text editor powered by tinymce.