greetings! i am trying my best to make a small project using servos and the sound sensor. I have been searching but cannot find help for making the sound sensor controlling the servo, would anyone be able to give an answer please? thank you
That's odd because when I search for "Arduino servo control by sound" I get loads of working examples.
Which Arduino, servo and sound sensor are you talking about. And what "controlling" do you want? Details are important.
Steve
slipstick:
That's odd because when I search for "Arduino servo control by sound" I get loads of working examples.Which Arduino, servo and sound sensor are you talking about. And what "controlling" do you want? Details are important.
Steve
arduino MEGA 2560, MG90S servo, im using the sound sensor from the arduino kit, not sure about the name, it doesnt show one. And the controlling i want is like, when there is talking, i want the sevo to move up and down, matching the talking speed.
matching the talking speed
Start with just the sound sensor and the on board LED, and learn how to make the LED to blink with the "talking speed", whatever that is.
i've already done this, just wanna take it to the next step. is it kinda the same but with different names for the devices?
For informed help, please read and follow the instructions in the "How to use the forum" post.
jremington:
For informed help, please read and follow the instructions in the "How to use the forum" post.
your post is irrelevant. I see nothing against what i am doing
One of the ideas in "How to use this forum" is that you get more and better help if you post the code you already have. Try it.
Steve
In order to give the best help we should be able to duplicate your project. That means that we need to see your code, a schematic of your wiring and data sheets for all of your applicable components.
slipstick:
One of the ideas in "How to use this forum" is that you get more and better help if you post the code you already have. Try it.Steve
my apologies, here is my code, i took a little bit from the ultrasonic sensor but that doesnt seem to be working, not sure how to get the audio thing to work, anyhow, here is my code
#include <Servo.h>
#include <NewPing.h>
const int TriggerPin = 3;
const int EchoPin = A0;
const int ServoPin = 2;
NewPing listener(TriggerPin, EchoPin);
Servo mouth1;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
mouth1.attach(ServoPin);
}
void loop() {
// put your main code here, to run repeatedly:
int cm = listener.ping_cm();
Serial.println(cm);
int angle = map(cm, 2, 15, 15, 180);
mouth1.write(angle);
delay(250);
}
i just realized i have the wrong name from the dictionary, what is the dictionary name for the sound sensor?
So what does that code do? What exactly is it supposed to do?
Unfortunately we don't know what "arduino kit" you have, there are dozens of different ones. But you did say in #4 that you had already used the sound sensor to make an LED blink. So post the code that you used for that and we can work from there.
Steve
slipstick:
So what does that code do? What exactly is it supposed to do?Unfortunately we don't know what "arduino kit" you have, there are dozens of different ones. But you did say in #4 that you had already used the sound sensor to make an LED blink. So post the code that you used for that and we can work from there.
Steve
i have the MEGA 2650 kit. Anyhow, i fixed the code a bit but it does not move the servo. The servo tries to turn but it only clicks and moves to the side slowly. Its not the servo, it does the same thing with the rest of my servos. Any how, here is the code.
#include <Servo.h> //call from library
Servo mouth1;
int micPin = 6;
int servoPin = 2;
void setup(){
Serial.begin(9600);
pinMode(micPin,INPUT);
mouth1.attach(servoPin);
pinMode(servoPin, OUTPUT);
mouth1.write(0);
}
void loop(){
int val = analogRead(micPin); //read the input on analog pin 0
Serial.println(val);
if (val>100){
mouth1.write(80);
delay(25);
}
else{
mouth1.write(0);
}
delay(25);
}
can someone look at this and let me know what is causing this issue?
How is the servo powered? I repeat, we need to see a schematic of your wiring.
mouth1.write(80);
delay(25);
Most servos take on the order of 200ms to move 60 degrees. Check the data sheet for your servo.
Read the how to use this forum-please read sticky to see how to properly post code and some advice on how to ask an effective question. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.
Remove the pinMode(servoPin, OUTPUT); The Servo library sets the pin up as needed so don't then mess with it.
It definitely sounds like you don't have enough power for the servo. But if you won't say how it is powered you're on your own there.
Also you're writing to the servo too often for it to be able to respond correctly. See what delay(300) instead of delay(25) does.
Steve
Do not attempt to power servos from the Arduino 5V pin. Use 4xAA instead, and connect all the grounds.