hearphones to light up a led!

That’s what I’ve done in two endless days:

advice for blondes: you don’t have necessarily  invest two days of your life to make the same sound sensor but just a bunch of minutes if you are well concentrated.

(If you want just see the tutorial and skip the story behind -and of course you’re a man if you don’t mind the story behind- go to Arduino for man| Tutorials)

day one: “Things are easy if you have an idea well scheduled!” – you have it, but that’s not always true.

Briefly the idea: take an old pair of earphones and convert them in a mic, so as a sort of sound sensor, then modulate the light of a led using the voice.

so I’ve transmitted my idea to my hands (blondes and few others as me require an extra dose of coffee for that) and I’ve start to work on my project.

That’s the plan:

  • take the earphones and cut one of them, taking out the wire and divide it in two parts.

  • make a circuit similar to the one we use to control a led by a button but replacing the button with the earphones.

  • control if Arduino is receiving the signal through the check of the port using the following command:
  • writing the codes and tell to Arduino to light up the led when there’s a sound input   and switch off the led when there’s no sound directly to the mic.

I’ve noticed a lot of difficulties during these apparently simple steps as:

the circuit: ‘a button circuit’ cannot correctly work with such a sound sensor, mic is different from a button even if both of them are analogic imputs, that could be immediate to someone but blondes are not just ‘someone’ they’re more and I’m with them so remember: YOU CANNOT ALWAYS USE THE SAME CIRCUIT  IN  SIMILAR PROJECTS, check online the features of the circuit you want to make and find out the right correspondence to your project.

When I saw that my sound sensor  was not working I ask myself why and right after I’ve ask it to Gorgio* (*Giorgio is the master of Arduino, the most similar person to McGyver  that I’ve ever seen,not  physically  and he has not that ridiculous haircut- I think that Giorgio himself would be glad of this specification-), he printed the port check and we just saw an endless series of zero , that’s mean that there is no signal passing through that port, so substantially there’s something wrong and of course it was the circuit.

Looking for a mic circuit online it’s not easy as it sound cause you will be in front of hundred of pages that explain you how to do a mic circuit, but you’ve to find out one the right one for your work, and even if is simple as a mic from an earphone will be not  immediately under your eyes.

Arduino is not just Arduino. Arduino is  puzzling.

I’ve found at http://www.epanorama.net/circuits/microphone_powering.html a circuit’s map suitable for the project:

caption for blonde: 
battery +ve= is the Arduino's 5 volt
output= is the Arduino's output- Analog in
GND,and battery -ve= don't mind at battery -ve, GND corresponds To GROUND in Arduino
CAPSULE + - = in this case + and - are the two wires we made out from the earphones but we don't know which is + or which is - what we know is that CAPSULE is the mic.
2k2-10k and 10uf = are resistors and capacitor, remember that you can compose a resistors riching the value by adding different resistors

reply the circuit on the bread board. As some of you can see and all the others can just image there are two resistors (2k2  R1-10K R2) and a capacitor (10uf) to plug in the circuit, 2K2 resistors between the 5 volt input and the mic (CAPSULE in the image) , the other by 10K between the ground and the output. Capacitor between the output and the mic.

Use the port to check if the signal works and so the circuit talking into the earphones. What I saw this time were numbers but the led was still off. The signal was too low to arrive to the led,  in fact the variation of numbers printed by the port was too small to have a visible effect.

day two: “Errors are the best way for learning”.And from the amount of your errors you should have learned a lot!

Day one ended with a fail, the earphone’s signal was too low to light up a led, so i looked for another mic, like the one from a telephone.

Marcello gave me his cell phone, well to be honest i was looking for a real phone, but trying doesn’t cost a thing, so i opened the phone looking for the mic.

I’ve spent half an hour trying to figure out which and where was the mic then I’ve understand that it was simply too small and it was impossible to work on it..well not with my trembling hand.

Next step:” A problem must have a solution. Otherwise is not a problem”.That’s it!

Wandering around at the university I’ve notice an unused red phone in room 306, so i ask to someone to go and ask the permission to destroy it – In Italy that’s how it works: if you need something you must have a lot of “friends”, with a lot of friends you can easily become first minister, if you are blonde  you can become one of the ministers of our current first minister :P-..well.. i had the permission so I smashed the red phone.

The telephone inside is something beautiful for a blonde: an explosion of bright colors and tiny and adorable pieces of plastic and metal, it looks like a futuristic city  from above, but what I was looking for it wasn’t in “the city” but in the periphery, so I smashed the handset too.

“The perfect mic!”, I though, so I started to work on that mic  soldering wires and extending them for a better plug into the bread board.

In the meanwhile Antonio join me in this adventure bringing with him a new revelation: a new circuit for the sound sensor discovered at http://lab.guilhermemartins.net/2009/05/03/sound-sensor/.

As you can see the new circuit is quite complicated for a blonde and requires some new stuff never met before to add.Operating both on the telephone’s circuit (taking off some parts) and on the telephone’s mic we have finally replied the circuit starting from a picture and as Giorgio said that’s “almost impossible”.

No signal.Nothing. Even with the new circuit.

Probably we made a mistake at some point, or all the items we put on the bread board weren’t just right, by the way the circuit was too complicated for us to understand when and where we got wrong.

That’s when we decided to get back at the previous circuit.

At the end of the day i was feeling miserable, because i was quite sure to have set everything at best, so i ask to Giorgio to give me a help.

He had simply got the multimeter and had tested if  there was electricity passing through the mic, the answer was easy NO! The wires were not connected in the right way and i felt as a stupid but happier than before.

After soldered the wires in the right way i made the program run using this code:

int sensorPin = 0;
int ledPin =11;
int sensorValue = 0;
void setup () {

Serial.begin (9600);
void loop () {
sensorValue = analogRead (sensorPin);
int ledPin = map (sensorValue, 0, 10, 0, 255);
analogWrite (11, ledPin);
Serial.println (sensorValue, DEC);
delay (5);

..and….ta taaaaaaaa:

it worked baby!

Now using a telephone’s handset you can light up a mic!