Pages: [1]   Go Down
Author Topic: connection between sound sensor and servo continuous rotation  (Read 506 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: February 24, 2012, 07:23:40 pm by elch » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 216
Posts: 13702
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Logged

Rob Tillaart

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

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
« Last Edit: February 24, 2012, 07:17:47 pm by elch » Logged

Pages: [1]   Go Up
Jump to: