Rather than just a card , flowers or chocolates this Valentine Day I decided to construct something appropriate using electronics - to share the fun. I have had a go at automating a musical box mechanism in the past (with no success - it was going to be for my Christmas Holiday contribution) and I recently became aware that you could buy the musical box mechanism without a spring needing winding up, you just turn a small hand crank - giving the ability to play at different speeds.
After some searching I found one that played a suitable tune (which Elvis Presley had recorded in the past) in a small wooden box (oreforde Engraved Music Box - Wooden Engraved Hand Crank Music Boxes -Can't help falling in love - Gift for Wife Girlfriend.: Amazon.co.uk: Kitchen & Home). I like the tune and my wife should like the tune.
I was originally going to 'remove' the crank in some way and directly drive the musical box cylinder but after some examination and considering of how to actually remove the handle (it looked difficult) I decided it would be better to leave the crank handle in place and just use a micro servo motor with an arm to turn it instead. For the controller I could have used almost anything as it only needs one digital output but I had some Arduino Nanos without headers so I used one of those. I wanted it to be battery powered but AA and AAA batteries take up considerable room and I wanted to keep the whole product as small as possible, so I used a LiPo battery. I had some 1000 mA hour batteries so I used one of those. As the Nano and the servo motor needed 5V or 6V really, I decided to use a small booster board to increase the 3.7V from the battery to 6.0V. I would have preferred a booster charger but the only ones I could find were far too expensive so when the battery goes flat I'll just unplug it and use the LiPo battery charger PCB I have. There are no other LEDs or sensors as there wasn't enough time to write the programme so the circuit is very simple and is illustrated below. Sorry the image is a bit dark, I'm not entirely sure why as there seemed plenty of light when I took the photograph.
I wanted to make a complete product this time so decided to design a 3D printed add-on box which just fitted to the right of the existing wooden box and was the same size. The crank handle is inserted through a large hole and a continuous rotation micro servo motor is just pushed into the slot designed for it to fit exactly, and is held perfectly by friction. I had to do a great deal of tinkering with the box to get the horn from the servo motor into the correct place and the micro servo motor into the correct place, so some hand fettling had to be done. For this reason I have not included the STL file because basically it isn't correct and there wasn't time to fix all the mistakes. The TinkerCAD view of the box is shown below.
The hole in the box at the back is because the crank handle just protrudes slightly so it was either a hole or a slightly bigger box. I went for the hole and then covered it over with a piece of white paper - it is at the back to so doesn't show. Not a great solution but the remaining time was being measured in minutes rather than hours. I would like to be able to claim that the compartment next to the servo motor was specially designed to hold the battery, Nano and booster PCB, but it wasn't. It is pure serendipity that I could manage to squeeze everything in - just. Sadly, because of a slight mistake with the positioning of the hole for the on/off switch (which I also forgot to add to the circuit diagram) there was no room inside the box for it's connections so I had to hot glue it to the front. Not a good finish but it works. I must get some better on/off switches.
The programme is also very simple, just being a for loop to output the required number of pulses needed to keep turning the musical box crank handle at the required speed and required duration, as listed below. Both the speed and duration were found by trial and error. It plays the tune and then stops. It has to be turned off then on again to make it play again.
/* Dubbie Dubbie
* Servo Musical Box
*
* 13th Feb'21
* Just for Fun
*/
#define testservo 2
void setup(void)
{
pinMode(LED_BUILTIN, OUTPUT);
pinMode(testservo, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(testservo, LOW);
delay(100);
Serial.begin(19200);
} /* setup */
void loop(void)
{
int width;
int count;
width = 0;
count = 0;
Serial.println("Servo Musical Box " );
Serial.println("Dubbie Dubbie : Just for Fun " );
Serial.println(" 13th Feb'21 ");
Serial.println();
delay(500);
digitalWrite(LED_BUILTIN, HIGH); // Shows it's working
delay(500);
digitalWrite(LED_BUILTIN, LOW);
width = 1500;
for (count = 0; count < 1050; count++)
{
digitalWrite(testservo, HIGH);
delayMicroseconds(200); // Makes up the 1 ms pulse
delayMicroseconds(width); // Makes up the rest of the pulse
digitalWrite(testservo, LOW);
delay(18); // The rest of the pulse
} /* for */
while(1)
{
/* Do nothing */
} /* while */
} /* loop */
The final complete and working product is shown in the video below.
It worked! There are problems. The micro servo is very noisy which I should have expected. When I was testing the servo I was only make small movements and it was very quiet. Once the servo was cranked up to the desired speed it was pretty noisy. I tried stuffing damping into the box and adding a lid but it was still intrusive. Fortunately the recipient didn't seem to notice. Afterwards I realised that it might have been much simpler to unscrew the mechanism from the supplied wooden box and just make a complete brand new box. Maybe next time, along with a much quieter motor.
Sadly(?), it is so well liked that I might not be getting the electronic parts back. Ah well, I'll just have to buy some more.
Dubbie
Top Comments