
Cameron
USA
Asked
— Edited
Hey Everyone!
I am currently stuck on how to code these 2 sound sensors (1 on left, 1 on the right)(picture below) on the head of my robot. I have a servo (D18) that goes up to 180 degrees and I want the head to turn towards the loudest noise level. I have looked at some examples and I still dont have any progress.
Any help would be appreciated
Thanks,
Cameron
What are the values that are being seen in the variable watcher when this runs?
Now you just need to modify the multipliers and the 500's to be what works for you.
Why do I do it this way? I am glad you asked
This will let you test the motor movement by itself. Once you know the motors move like you want it to, you can quit messing with it and know it will work. You can also reuse this script for other sensors added later if you want to.
The sensor reading script can be tested without calling the servo script. Once that one works as you expect, you dont have to worry about it anymore and can reuse it if you want to.
I try to make my scripts do one thing only to eliminate extra stuff in a script that makes it difficult to change or modify in the future.
I adjusted the values a few times and it still goes to one side and not the other. Here is the script I am using:
Code:
I even tried the 2 put together you posted and it still did the same thing. I know I am missing something here just not seeing it...
Yeah im sorry i meant to add you to the thread as well. I have ran the script multiple times and it does show 1 having a bigger value in the variable list. But at another time they are both over 100. I'll try again and even switch them like you said.
Thank you
Code:
Are you trying to comment out the 100 for your reference? Unless I was not aware of this being OK, I don't think you can use a * to comment out something. I've always used this character: #
I think he has a sensor that os messing up or reporting much lower than the other but that is just a guess.
Code:
So this * forces the ACD reading to a wanted value? I'm not understanding this. Sorry. Can't find this in the EZ Script manual. *confused*
It may be that one mic has a lower return for some reason. He can use this multiplier to get both of them close to the same by setting one to *84 and the other one * 100 for example.
Use this script and then follow the directions recording the values of the left and right sensor after the value is stated by the robot. This should help you determine what is going on.
Code:
https://www.ez-robot.com/Community/Forum/Thread?threadId=6814
@Dave Schulpius. The * is for multiplication.
The closest I got to set them to are:
Left Side 86
Right Side 78
I tried to adjust and made them as close as i could with the sound test script that @CochranRobotics put up and it did help. Now I just need to figure out how to adjust and multiply accordingly?
Here is the script I have been trying to still use: (Which I have messed around with numerous times and still nothing)
Code:
The OP hardware is this:
https://www.adafruit.com/product/1063
this is not a sound sensor, this is a microphone with an amplifier, if you read the documentation you will find:
this means in a perfect scenario no sound will be 128 = VCC/2, also the value will oscillate below and above the DC Bias.
more info here:
http://www.instructables.com/id/Arduino-Audio-Input/
bhouston posted a thread:
https://www.ez-robot.com/Community/Forum/Thread?threadId=6814
The hardware used is different:
v2 version:
https://www.dfrobot.com/wiki/index.php/Analog_Sound_Sensor_SKU:_DFR0034
v1 version
https://www.dfrobot.com/wiki/index.php/Analog_Sound_Sensor_(SKU:_DFR0034)
I'm not 100% sure but the amplification (check the schematic) is different is a linear value.
In the same thread, Richard mentioned an ebay sound module similar to this one:
http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/arduino-sound-detection-sensor-tutorial-and-user-manual/
the sensor is different, you setup a set point, and the sensor will return a single value HIGH or LOW if the sound is above or below the set point.
If someone has a working solution, please share the hardware/script used.
Sound sensor
Thank you for your help with that. And thank you to everyone else as well.
@Richard R thank you as well. Ill get that sensor