Project showcase
Overly Complicated Bubble Machine

Overly Complicated Bubble Machine © LGPL

Bubble machine utilizing three servos and a DC motor.

  • 9 views
  • 0 comments
  • 0 respects

Components and supplies

About this project

My kid loves bubbles, so I decided to make a bubble machine for him.

This project includes a Python script for your PC if you want the music to play and don't have the proper shield for Arduino. You will need to have your PC connected to Arduino via USB to have both parts work. If you have an Arduino with WiFi, you could manipulate the connection portion of the code in both scripts to facilitate the same process without using a USB connection.

The basic rundown is as follows:

When powered on, the servos initialize to the specifications set in the code. Once the button is pushed, it sends a command to your python script running on the PC, It will move the wand down, dip it into the bubble liquid, pull the wand out of the liquid, pause to let excess liquid drip into the bowl, move the wand to in front of the fan, at which point the fan will turn on and the base servo will sweep the machine left and right blowing bubbles.

NOTE: The bubble wand will need to be adjusted for maximizing bubble output. For my home made fan blades, I found having the wand slightly canted instead of flat produced more bubbles. If making your own fan blades, you will need to tinker with the design of the blades, and both the angle of the motor and distance of the motor from the bubble wand.

I enclosed everything in tupperware containers and sealed everything with clear silicone. Since everything is in a plastic container, the L298 is not properly grounded. You will need to connect the ground wire from the motor to the GND connector on the L298 instead of putting it in OUT3/OUT4 in order to get the motor to work.

Video:

https://www.reddit.com/r/shittyrobots/comments/fwv5gj/i_made_an_overly_complicated_bubble_blower_that/

WARNING: USING HOT GLUE AS A SEALANT IS NOT RECOMMENDED because it won't flex with the container and the seal will break causing leaks that can destroy your components.

Code

Bubble Machine Code ArduinoC/C++
#include <VarSpeedServo.h>  //Gives you control of servo speed

//IMPORTANT NOTE: With VarSpeedServo, you can control the degree and speed of the servo. Example: "servo1(76,60,true)" calls servo1, tells it to go to 76 degrees, at a speed of 60 (1=slowest, 255=fastest).

VarSpeedServo servoH; //Base servo for horizontal sweeping motion
VarSpeedServo servoV; //Vertical servo connected to base servo
VarSpeedServo servoW; //Wand servo connected to Vertical servo, controls vertical motion of bubble wand

int in3 = 3;     //IN3 on L298 connected to pin 3
int in4 = 4;     //IN4 on L298 connected to pin4
int pos = 0;     //I think this is left over code from previous trials, but never removed it. Have not tried to run code without this
int button = 11; //Button is connected pin 11
int buttonstate = 0;  
void setup() 
{
 Serial.begin(9600);
 Serial.println("Hi! It's Arduino!");
 pinMode(in3, OUTPUT);
 pinMode(in4, OUTPUT);
 servoH.attach(6);    //Attaches Horizontal Servo to pin 6
 servoV.attach(7);    //Attaches Vertical Servo to pin 7
 servoW.attach(8);    //Attaches Wand Servo to pin 8
 servoH.write(0,255,true); //Initializes Horizontal Servo, 0 degrees, 255 speed (same with next two)
 servoV.write(0,255,true);
 servoW.write(0,255,true); 
 pinMode(button, INPUT);   
 digitalWrite(button, HIGH);

}


void on() //Motor on
{
 digitalWrite(in3, HIGH);
 digitalWrite(in4, LOW);
}


void off() //Motor off
{
 digitalWrite(in3, LOW);
 digitalWrite(in4, LOW);
}


void center() //You will need to adjust the degrees in these settings. This centers the machine according to servo orientation and where my bubble liquid bowl is
{
  servoH.write(76,60,true);
  servoV.write(80,60,true);
  servoW.write(50,60,true);
}


void sweep() //This turns the fan on, sweeps the machine, and turns the fan off. Servo degrees may need adjustment depending on servo orientation
{
 on();
 servoH.write(120,15,true);
 servoH.write(50,15,true);
 servoH.write(90,15,true);
 off();
}


void dip() //You will need to adjust the degrees in these settings. This uses the Vertical servo to raise the Wand servo, 
           //then the wand servo turns the wand downward, Vertical Servo lowers wand servo, raises it up,
           //pauses to let excess fluid drip off, Wand servo raises the wand, Vertical servo lowers. 
{
 servoV.write(80,60,true);
 delay(200);
 delay(1000);
 servoW.write(120,40,true);
 delay(200);
 servoV.write(150,60,true);
 delay(1000);
 servoV.write(100,60,true);
 delay(200);
 servoV.write(150,60,true);
 delay(200);
 servoV.write(80,40,true);
 delay(3000);
 servoW.write(40,60,true);
 delay(200);
 servoV.write(100,60,true);
 delay(200);
}




void loop() 
{
 buttonstate = digitalRead(button);    
 buttonstate == HIGH; 
 center();
 if (buttonstate == LOW) //when button is pushed, it causes a ground, moving the buttonstate to LOW, triggering the loop
 {
  Serial.print('1'); //This is done three times, because otherwise the python program will only play the music every other button press
  Serial.print('1');
  Serial.print('1');
  dip();
  sweep();
  
 }
}
Bubble Machine Python Code for PCPython
import time
from pygame import mixer #music player
import serial

mixer.init()
mixer.music.load("C:/Users/") #Set this to the directory of the mp3
ser = serial.Serial('COM5', 9600) # set to arduino COM and baud
ser.flushInput()

while True:
    print(ser.read().decode().strip()) #Decodes and prints what Arduino sends
    if str(ser.read().decode().strip()) == "1":  #When '1' is sent from Arduino when the button is pushed initiate loop
        print(ser.read().decode().strip())
        print("here we go!")
        mixer.music.play()
        mixer.music.play()
 

Schematics

Bubble Machine Picture 1
20200410 104347 k9ipsiklfo
Bubble Machine Picture 2
20200410 104400 bxo9nfyg7e
Bubble Machine Picture 3
20200410 104409 h3eetbbtpz
Bubble Machine Picture 4
20200410 104419 btedhr6xj5
Bubble Machine Picture 5
20200410 104432 wjm0aw5pit
Bubble Machine Wiring JPG
Bubble machine bb 59rytox3k6
Bubble Machine Wiring
bubble_machine_bx6MgESuXm.fzz
Music for bubble machine
mp3 file if you want to use it
yaygettowork_v5emNtuJEF.mp3
Bubble Machine Code
bubble_machine_7gjNrqb3hl.ino
Python code
This is the python code for playing the music
bubblemachine_pJu5NXo7Ei.py

Comments

Similar projects you might like

Make-It-Rain Clap Machine

Project tutorial by Arduino_Genuino

  • 7,990 views
  • 1 comment
  • 18 respects

Distinguish walking and running using Machine Learning

Project tutorial by Jayraj Desai

  • 5,392 views
  • 2 comments
  • 24 respects

ATmega Alien Themed Slot Machine

Project tutorial by Dan Murphy

  • 3,281 views
  • 6 comments
  • 25 respects

Controlling Arduino State Machine via Web

Project tutorial by phpoc_man

  • 2,605 views
  • 4 comments
  • 23 respects

Arduino-Based Bitcoin Candy Vending Machine

Project tutorial by Team Elkrem

  • 9,604 views
  • 19 comments
  • 57 respects

Little Rover

Project tutorial by Jeremie

  • 8,015 views
  • 8 comments
  • 20 respects
Add projectSign up / Login