
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
Richard handles that in his sleep 2000 statements above. Also, he is centering the servo. If you dont have it, I would still add the Variable watcher so that you can see what is happening along with using it to see the set variables too, which will help you debug.
Gotcha! Thank you!
@Cameron You may need to tweak the values a little to get it working the way you want it to....
Will do!
@Richard R @CochranRobotics
Soo....it still is continuing to always move back and fourth to the left confused
I did check and set the variables to what it said. I even messed with the values from the last example and it still is doing the same thing. Is there an example that is spot on? I have looked, tried changing it and it still is going always one direction when the code is running. Always goes just to the left..
Can you post your entire script here? If I don't get a chance to look at it, someone will.
You can debug by setting the parameters in the script to see if the reaction is as expected. Then, you just need to see what the values of the variables are from the VariableWatcher control to see what you are actually getting for values.
Post the script and I will take a look at it to see if I can see anything specific that might be causing an issue.
Try this and see if the head moves right
Also, do you have the Variable Watcher in your project? If not, add it so you can see what the variables are being set to. If so, please let me know what they are being set to. I suspect the issue is with the sensor more than the script.