Building a soap bubble machine is a nice little project for children in the age of 8 to 12 years. Playing with the machine is fun for children in the age of 3 to 99 years.

Required Hardware

1x Arduino – we used an Arduino Uno

1x Servo motor

1x DC motor

1x condensator 100 uF

1x resistor 10 kOhm

1x push button

1x diode


1x battery holder 9V


Connecting the Servo

Electric motors may use a lot of electrical energy especially if they start working. Therefore never directly connect a motor to your microcontroller – it is not able to provide the needed current.

Starting a motor may draw so much current that the circuit will experience a short decrease in voltage. You can omit this if you place a condensator in the circuit to decouple the motor from the circuit. This means the condensation works as energy buffer. But attention: Plug the condensator correctly – otherwise it could explode.

Connect VCC of your servo the plus of your battery and GND to minus of the battery. Place a 100 uF condensator between VCC and GND. Connect the input pin of the servo to pin A1 of your Arduino.

Connecting the DC motor

In order to be able to switch the motor we use a MOSFET. Connect the gate of the MOSFET to Arduino pin 6, its source with ground and its drain with the plus pin of the engine – put a diode in the latter wire to protect the circuit. If the DC motor is switched off it does not stop immediately. As long as it is turning it works as a generator. To keep the current generated off the circuit, we place the diode in the wire.

Connecting the Button

Connecting the button is not really tricky. Its function also is not really important. Its only function is to start the machine. Without it the machine would start as soon it is powered, but to be able to set everything without a hurry, the machine starts working only if the button was pressed. I did not use the button as a stop button, because in this case we would have to need implement interrupt service routines. This is a project for starters, so I decided to not introduce ISPs.


The defines SERVO_OBEN (upper dead point of servo) and SERVO_UNTEN (lower dead point of servo) can be used to adopt the sketch on your construction.

PUSTEZEIT_IN_S is the time the machine blows air in seconds. WARTEZEIT_IN_S is the delay time between two iterations in seconds.

#include <Servo.h>

#define schalterPin 7
#define motorPin 6
#define servoPin A1

#define SERVO_OBEN 85
#define SERVO_UNTEN 0
#define PUSTEZEIT_IN_S 4
#define WARTEZEIT_IN_S 2

Servo meinServo;
int servozustand = LOW;
int schalterzustand = LOW;

void setup() {

schalterzustand = LOW;

pinMode(schalterPin, INPUT);
pinMode(motorPin, OUTPUT);

digitalWrite(motorPin, LOW);

void loop() {
int schalter=digitalRead(schalterPin);

if( schalter == HIGH ) {
if(schalterzustand == LOW) {
schalterzustand = HIGH;
} else {
schalterzustand = LOW;

if(schalterzustand == HIGH) {
Serial.println("Der Schalter wurde gedrückt. Servo ist unten");

Serial.println("mein servo fährt nach oben");

Serial.println("motorPin geht an" );

digitalWrite(motorPin, HIGH);

Serial. println("motor geht aus");
digitalWrite(motorPin, LOW);

Serial.println("servo unten");
} else {

digitalWrite(motorPin, LOW);