The Tiny Violin

I found a small violin lighter online. Since I have better things to do with my hard-earned money than give big wads of it to Faceless Multinational Corporations and the Government in return for a massively increased risk of an early death, I had an alternative use for it....

Repurpose repurpose repurpose.

Having gutted the lighter mechanism and fuel resovior, and dremmiled off some of the internal supports, I used some double-sided foam tape to stick an Arduino Micro in the case, cutting out a slot in the bottom for the Mini-USB B-port.

Exploded view of 'violin'

I also double-sided-foam-taped an 8-ohm phone speaker on top. Grinding out a little slot in the opposing face of the 'violin' helped the sound get out better. The speaker is connected arross pins 2 and GND.

The little hole at the top where the flame used to come out was perfect for a salvaged push-button switch. The hole even had an aluminium support behind it to keep the switch in place! A 10k-ohm pull-down resistor between ground and Pin-3 and the switch between 5V and Pin-3 complete the circuit. This is a standard switch-sensor as per the Arduino Button Tutorial.

Then it is screwed snugly back together:

'Violin' all put back together.


I adapted the arduino example Tone Melody, which also requires the pitches.h file as per the page just linked. I programmed it with the best version I could work out by-ear of "My Heart Bleeds for Thee."

/* Based on Arduino example 'Melody' by Tom Igoe, 2010-2011 This example code is in the public domain. */ #include "pitches.h" // notes in the melody: int melody[] = { NOTE_E3, NOTE_C4, NOTE_B3, NOTE_A3, NOTE_G3, NOTE_D3, NOTE_E3, NOTE_A3, NOTE_D3, NOTE_D3, NOTE_E3, NOTE_D3, NOTE_CS3, NOTE_F3, NOTE_E3 }; // note durations: 4 = quarter note, 8 = eighth note, etc.: int noteDurations[] = { 4, 4, 2, 8, 4, 4, 2, 8, 8, 8, 8, 4, 4, 2, 2 }; void setup() { // initialize digital pin 11 as an output. pinMode(2, OUTPUT); // the speaker pinMode(3, INPUT); // the button tone(2, 10000, 100); // go "pip-pip" when power-up complete. delay(200); tone(2, 10000, 100); } void loop() { while(digitalRead(3) == 0); // loop until button pressed // iterate over the notes of the melody: for (int thisNote = 0; thisNote < 15; thisNote++) { // to calculate the note duration, take one second // divided by the note type. //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc. int noteDuration = 4000 / noteDurations[thisNote]; tone(2, melody[thisNote]*2, noteDuration); // to distinguish the notes, set a minimum time between them. int pauseBetweenNotes = noteDuration * 1.0036125; delay(pauseBetweenNotes); // stop the tone playing: noTone(2); } delay(400); // slight delay before repeating if the button is being held. }

And that's it! A nice quick one.

Sorry about the background noise!


upBack to Glenn's Project page.