Go Down

Topic: connection between sound sensor and servo continuous rotation (Read 537 times) previous topic - next topic

elch

Feb 24, 2012, 06:17 pm Last Edit: Feb 25, 2012, 01:23 am by elch Reason: 1
Hello everybody,
I want to control the speed of a continuous rotation servo based on the values I get from a sound sensor.
I am using an electret microphone combined with an amplifier bought from this team (http://www.interface-z.com/pronfiture/sans-contact/202-volume-sonore.html)
an arduino card and a servo. My problem is that seperately both things work perfectly fine, the micro shows a variation between 0 and 1023 corresponding to the sound. I have tried
the simplest connection between them with an if command basicly saying if value < 800 the servo has one speed else > 800 the servo has another.
The problem is that the microphone once it is connected in the circuit with the card and the servo, it loses its ability to show variation and the only value I get is
the maximum 1023. Can anyone explain why this happens and if there is a possibility to combine those two things?

Thank you

robtillaart

Quote
Can anyone explain why this happens and if there is a possibility to combine those two things?


Can you post your schematic (a drawing is ok) of all wires incl GND, mike, servo etc
and please post the code of the sketch?

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

elch

#2
Feb 25, 2012, 01:16 am Last Edit: Feb 25, 2012, 01:17 am by elch Reason: 1
I give you a graphic representation of the connections I have tried, I am  not at all familiar with the scematics
of electronic circuits so excuse me if it will look weird. I show the simplest way i could think for the connection.
I have tried to give power to the servo not from the computer but from a seperate battery.
http://imageshack.us/photo/my-images/196/scematics.jpg/


This is the scetch I have written in its simplest form.
73 is the value with which the particular servo stops

#include <Servo.h>

int sensorValue = 0;
int servoRightPin = 2;
Servo servoRight;

void setup()
{
 servoRight.attach(servoRightPin);
 Serial.begin(9600);
}

void loop()
{
 sensorValue = analogRead(A5);
 Serial.println(sensorValue);
 if (sensorValue < 800){
   servoRight.write(73);
   delay(30);
 }    
 else if (sensorValue > 800) {
   servoRight.write(0);
   delay(30);
 }
}

Thank you again!

Go Up