Required parts
Arduino (UNO R3 used here)Bubble machine
Relay board (I used one with two modules, but one module is enough)
LED
Resistor 1kΩ
Optional:
- prototyping shield
- mini breadboard
or
- normal breadboard
These two parts are not required, one can use a normal breadboard, if preferred. The picture below not in proportion to the mini breadboard above.
Disassembling the Bubble machine
The Arduino sketch is dead simple. What I found trickier, was dealing with the hardware. Connecting everything together correctly, though, after I understood, how it all works, it is fairly simple too.- Unscrew the back of the machine, to get to the wires.
- The motor is connected to:
- the battery combo (negative change)
- the switch
- The battery combo is connected to:
- the motor
- the switch (positive charge)
- Disconnect both wires from the bubble machine switch
Hardware connections
Connecting the Bubble machine to the Relay module
The Bubble machine wires will be connected to the relay board on the left side, Arduino on the right.
On the left, there are 3 connections (from the top):
- NO ... Normally open (circuit)
- COM ... Power
- NC ... Normally closed (circuit)
We need to connect the battery wire to NO and the motor wire to COM.
Connecting the Relay module to Arduino
On the right side of the Relay board, there are several connections:
- GRD ... Ground
- VCC ... Power
- IN1, IN2 etc ... Relay board output pins (each pin corresponds to one relay module)
The Relay GRD will be connected to the Arduino GRD, VCC needs to be connected to Arduino V5 pin and one of the Relay output pins will get attached to whichever Arduino digital pin we like. This pin will be used to control the Bubble machine.
NOTE
Please note that the setting:
digitalWrite(controlPin, HIGH);
will NOT start the engine, because the default mode of the NO-COM connection is an open circuit. Rather counter-intuitively, we can start the engine with:
digitalWrite(controlPin, LOW);
which closes the circuit by switching off the default, ie "not connected"/"open" setting to the non-default/"closed" one.
The Arduino Sketch
/* Control the bubble machine (powered by batteries) bubble machine is switched on at start, then off and on again a LED switches on when the machine is off and vice versa
*/ int controlPin = 7; void setup() { pinMode(controlPin, OUTPUT); digitalWrite(controlPin, LOW); // turn the bubbles on,
// the LED is off
} // the loop routine runs over and over again forever: void loop() { digitalWrite(controlPin, HIGH); // turn the LED on and bubbles off delay(6000); // wait for 6 seconds digitalWrite(controlPin, LOW); // turn the LED off and bubbles on delay(6000); // wait for 6 second }
The effect is that the Bubble machine, as soon as we power up the Arduino, will start and go on for 6 seconds. Then it will stop and the LED will light up for 6 seconds. Then the machine will be powered up again and the LED will be switched off for 6 seconds and so on and so on ...
No comments:
Post a Comment
Note: only a member of this blog may post a comment.