I've recently begun working with Arduino and I have no idea about electronic components but I'd like to learn.
I want to create an interactive fan which is activated by sound or human voice. According to my research I need an electret microphone and a DC motor. The electret microphone detects the sound and activates the fan. I'm unsure if they are the right components to start with.
My question is how are the components connected with the Arduino? I know I need a transistor, a capacitor and some resistors but I don't know how connect them.
First of all, thank you very much for your soon reply and help.
As Richard asked, I've got a little experience in programming, I am able to understand the code and change it but I can't start writing from zero.
The DC motor is done, thanks again. However, I found difficulty reading the thread you recommended me so I came across other good link and I'd like to get your opinion about it: http://www.iua.upf.es/~jlozano/interfaces/microphone.html
Apparently, the documentation works with an electret microphone. I don't know how to read circuit sketch but I'm going to try... Could you possibly tell me if I'm right?
A piezo buzzer is used in this case but it can be replaced it for a microphone as the video shows . The microphone has to be connected to the transistor Base, a 100K resistor has to be between both and the other resistor side has to go to +5V as well. Similarly, the transistor Collector goes to 22K resistor that goes to +5V too. I don't get the rest of the circuit (Emitter of the transistor). I know there is a 10uF capacitor and it could be a potentiometer but I'm unsure
That 100K connected to the base is actually a pot. These have three wires and the central one, the wiper, is connected to the base.
The emitter (the one with the arrow) is connected to a 3K3 resistor to ground. It is also connected to a 1K pot, this time the wiper is connected to on end to make a two terminal device. The other end is connected to the positive end of a 10uF capacitor with the other end to ground.
Vout is connected to the arduino analogue input.
RM controls the gain of the amplifier and the other pot controls the bias which should be adjusted so that any clipping applies symmetrically to the waveform. Just set the to the middle.
I connected a transistor among the ground, 5v, 9V battery and the DC motor to amplify the electrical signal. On the other hand, I connected the microphone. This includes a small green board that shows GND, 5V and AN. It has more holes like TX, RX and BW but I didn't use them. Consequently, I wrote the following lines in Arduino:
//it reads the microphone input
int mic = 5;
//it stores the microphone input
float val = 0;
//declares the variable that stores the transistor output
//the transistor is amplifies the electronic signal to the DC motor
const int transistorPin = 9;
I'm struggling with the calibration because the DC motor sometimes doesn't work when you talk through the microphone or keep spinning even if there is silence... it looks to me the microphone is broken or connected wrongly...
The serial print gives me 300 - 350 when is quiet and 10-30 when you talk through it. It works inversely....
For the moment forget about the motor control and just print out the value you are getting from the microphone. You will probably find that is all over the place.
You need a diode on the analogue input and a capacitor across the input. This will allow you to only measure the peaks of the sound waveform and also keep out the negative part of the audio waveform which is making the motor stop.
Add a delay(300); so that you are not sampling things so often. then add the motor control back again.
You can also average say 10 readings before you attempt to do the control.