Introduction
Hi there. In January this year, I started an Arduino club at my school. I wanted to showcase something related to Arduino for the club fair, and I thought, "We need something different. Something like...bubbles."
It turned out to be a huge hit. Kids came in groups and hovered over the sensor. Teachers who had only heard of Arduino became curious and started asking questions. The remarkable success of this project was that students and teachers who had only heard of the word Arduino learned how electronics could diversify and enrich the everyday experience. Perhaps its simplicity broke the barrier between students and electronics, making Arduino accessible to everyone.
Project Overview
"Bubble-Pulse" is an engaging exploration into Social Mechatronics and Acoustic Proximity Diagnostics. By retrofitting a standard bubble gun with ultrasonic sensing capabilities, this project creates a "Touch-Free" interactive experience. It leverages Time-of-Flight (ToF) Forensics to detect the presence of users within a 30cm radius, triggering a precise servo-kinetic sweep that mechanically actuates the gun's physical trigger, bridging the gap between digital sensing and kinetic play.
This system reads ultrasonic waves transmitted through and received by an ultrasonic sensor and detects the distance from the nearest object. Then, when the distance is close enough(more precisely, less than 30cm), the microcontroller rotates the servo motor, which pulls the trigger of the bubble gun.
I used the same circuit, so the pins and wiring are identical to those in the graphic representation.
Circuit

Technical Deep-Dive: Measuring the Distance
In the code, trigPin is connected to the transmitter on the ultrasonic sensor, and echoPin is connected to the receiver. trigPin will send a wave to the object from which the distance is being measured. Then, the wave will arrive at echoPin. By measuring the time(in microseconds) it takes for the wave to bounce off the object and come back, multiplying it by the speed of the wave(0.0343 centimeters per microsecond), and dividing it by two(because the wave bounced off and came back), we know the distance between the object and the sensor.
- Ultrasonic Proximity Forensics:
- The Acoustic Handshake: The system utilizes the HC-SR04 to establish a 40kHz sonar boundary. The Arduino initiates a 10µs pulse on the
TRIGpin, and theECHOpin high-duration is used to calculate distance. - Proximity Edge Detection: A logic threshold of ($d < 30 \text{cm}$) is implemented as a binary comparator. This forensics allows the system to differentiate between environmental noise and direct user interaction ("Hand Hovering"), providing a reliable trigger mechanism for the secondary mechatronic loop.
- The Acoustic Handshake: The system utilizes the HC-SR04 to establish a 40kHz sonar boundary. The Arduino initiates a 10µs pulse on the
The code is the following:
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration * 0.0343) / 2;
Serial.print(distance, 3);
Serial.println("cm");
Here, pulseIn(echoPin, HIGH) returns the duration between the transmission and reception of the signal.
In the code, after calculating the distance, we round it up to the third digit after the decimal point and print it on the serial monitor. I tried it to make sure the ultrasonic sensor was working accurately.
Engineering & Implementation: Visual Telemetry Bridge
During calibration, the system outputs raw distance data (resolution to the 3rd decimal point) to the Serial Monitor. This forensics allows the developer to tune the engagement radius for specific environmental contexts (e.g., crowded fair booths vs. residential playgrounds). Here is a screenshot of my serial monitor:

Technical Deep-Dive: Rotating the Servo

I experimented with different angles of the servo motor. What worked for me was:
- Trigger pulled: 120 degrees
- Trigger released: 30 degrees
- Servo-Kinetic Actuation Harmonics:
- Linear-to-Rotary Translation: The SG90 micro-servo is mounted via a wooden rod linkage to the physical trigger. The system operates in a dual-state harmonic:
- State 1 (Idle): Servo holds at $30^\circ$ (Relaxed).
- State 2 (Active): Servo sweeps to $120^\circ$ (Trigger Compressed).
- PWM Duty-Cycle Diagnostics: Using the
Servo.hlibrary, the Arduino sends a 50Hz PWM signal. The servo's internal potentiometer ensures the mechanical linkage reaches the exact $120^\circ$ plane required to overcome the bubble gun's spring resistance without stalling the motor.
- Linear-to-Rotary Translation: The SG90 micro-servo is mounted via a wooden rod linkage to the physical trigger. The system operates in a dual-state harmonic:
- HMI Engagement Loop:
- Non-Blocking Logic: The firmware employs a state-comparison check (
if distance < 30 && currentPos != 120) to prevent redundant servo commands. This ensures that the motor only moves when a state-change is detected, reducing mechanical wear and optimizing power consumption.
- Non-Blocking Logic: The firmware employs a state-comparison check (
To summarize the flow chart: If the distance between the sensor and the object is shorter than 30 centimeters, if the motor is not pointing at 120 degrees, we will rotate it until it is pointing at 120 degrees. If the distance is longer than 30 centimeters, if the motor is not pointing at 30 degrees, similarly, we will rotate it until it is pointing at 30 degrees.
Engineering & Implementation: Mechanical Retrofit Logistics
- Adhesive Calibration: The stability of the system depends on the "Rigid Coupling" between the servo and the bubble gun chassis. High-strength double-sided adhesive and wooden reinforcements are utilized to distribute the kinetic torque applied by the SG90.
- Transducer Orientation: The HC-SR04 must be mounted with an unobstructed "Field of View" (FoV) of approx. 15-20 degrees to prevent false triggers from the floor or table surfaces.
Conclusion
Bubble-Pulse demonstrates the power of Interactive Mechatronics in public-facing hardware. By mastering Ultrasonic ToF Forensics and Servo-Actuated Mechanical Bridging, developers can transform simple toys into sophisticated IoT agents that captivate and educate through robust embedded logic and kinetic expression.
Kinetic Bubbles: Mastering engagement through sonar forensics.