DIY Bubble Machine Using Raspberry Pi Pico 🫧

Photo of Aula_Jazmati

Made by Aula_Jazmati

About the project

The project aims to create a soap bubble machine using a perforated plastic disc attached to a DC motor and a fan.

Project info

Difficulty: Easy

Platforms: SparkFun

Estimated time: 1 hour

License: MIT license (MIT)

Items used in this project

Hardware components

Axial Fan, Brushless Motor Axial Fan, Brushless Motor x 1
SB Components raspberry-pi-pico-board-gpio-expansion SB Components raspberry-pi-pico-board-gpio-expansion x 1
Jumper wires (generic) Jumper wires (generic) x 1
SparkFun Dual H-Bridge motor drivers L298 SparkFun Dual H-Bridge motor drivers L298 x 1
DC Motor, 12 V DC Motor, 12 V x 1
Raspberry Pi Pico Raspberry Pi Pico x 1


🫧 Introduction:

The project aims to create a soap bubble machine using a perforated plastic disc attached to a DC motor and a fan. These components are connected to an L298 driver circuit and controlled by a Raspberry Pi Pico microcontroller. This simple and enjoyable project is designed for children to learn about electronics and programming.

Soap bubbles have always fascinated children and adults alike. They bring joy and excitement, creating beautiful floating spheres that reflect light in mesmerizing colors. With this project, children can explore the science behind soap bubbles while having fun building their own machine.

The heart of the machine is the perforated plastic disc, which acts as a bubble wand. When the disc rotates, it dips into a soap solution, creating a film of soap on its surface. As the disc spins, air from the fan blows through the holes, forming bubbles that detach from the disc and float away.

To control the rotation of the disc and fan speed, we use a DC motor connected to an L298 driver circuit. The L298 driver allows us to control the direction and speed of the motor using signals from the Raspberry Pi Pico microcontroller.

We control the speed of the perforated circular bubbles disc through a potentiometer connected to an ADC pin at the Raspberry Pi Pico.

The Raspberry Pi Pico serves as the brain of our project. It runs a program that controls when to start and stop the motor, as well as adjusting its speed. By programming the Raspberry Pi Pico, children can learn about coding concepts such as loops, conditionals, and functions.

This project not only introduces children to basic electronics but also encourages their creativity by allowing them to customize their bubble machine. They can design and decorate their own plastic discs or experiment with different fan sizes for varying bubble sizes.

In conclusion, this DIY project offers an exciting opportunity for children to learn about electronics, programming, and physics while having fun creating their own soap bubble machine. It combines science with creativity in an engaging way that will captivate young minds. So let's dive into this project together and explore the fascinating world of soap bubbles! 😙🫧🫧🫧







The following picture shows the Raspberry Pi Pico pinout (which functions are supported by each pin).

Raspberry Pi Pico Pinout

Raspberry Pi Pico Pinout

Raspberry Pi Pico Pinout

🫧 How to Initialize PWM in MicroPython for Raspberry Pi Pico?

We are going to follow the steps stated below in order to configure PWM in our Raspberry Pi Pico.

  • Firstly, we have to choose the PWM pin.
  • Next, we set a particular frequency for our digital signal. 50Hz is a good value to start off with to work with an LED and L298.
  • Raspberry Pi Pico has 12 bit resolution but in MicroPython it is scaled to 16 bits. Hence the duty cycle will be set from 0-65535 which corresponds to 0-100%

You can read this article on Raspberry Pi Pico ADC:

Inside the infinite loop we are reading the analog pin through the method read_u16() from the potentiometer variable and storing it in potentiometer_value. This value will vary from 0-65536 because we have 16 bit resolution. You will be able to see the values getting printed on the screen. This value is given as a parameter inside the duty_u16() method which is being accessed through the led and motor speed.

When you run this code on your Raspberry Pi Pico and rotate the potentiometer knob, you will get the value of ADC after every 1 seconds.

1 / 3

Increasing input values from the potentiometer act as increasing duty cycle hence the brightness of the led increases and the speed of motor of bubbles disk..

The blower fan and Raspberry Pi Pico were powered by a power bank. The drive module L298 is powered by an external battery.


  • The smaller the disc area, the greater the possibility of bubbles sticking to each other, so it is preferable to use a larger disc with proper spacing of the holes.
  • You should also use a powerful fan to blow bubbles, such as fans that rely on a Brushless motor.
  • Using a variable resistor (potentiometer) we calibrate the disk speed to obtain the desired performance.

🫧 Test The Machine 🫧😊🫧

1 - WokwiSimulationTest:

2 - RealTest :

1 / 4

1 / 2

🫧 References:


The machine code


Photo of Aula_Jazmati



Leave your feedback...