Darwin-River / Robotics

0 stars 0 forks source link

Code a robot that runs when it hears a sound #3

Closed darozak closed 1 year ago

darozak commented 1 year ago

Now that I have a fully assembled robot. I'd like to code it to briefly run the servos when it hears a sound.

darozak commented 1 year ago

Following a good YouTube video about using the sound sensor (https://youtu.be/PYkzJQhFNlA), I created a simple code that runs the servos when it hears a sound (https://github.com/Darwin-River/Robotics/commit/956863db0f40f18a6934159f23cb061c9a354e9a). However, right now the readout is binary and any random ticks in the motor are enough to cause it to start running on its own.

I need to follow the instructions in the video to generate an non-digital value and respond only to loud sounds.

darozak commented 1 year ago

Following the video, I created and tested some code that will detect frequency of an incoming sound. I documented this in Scrivener (https://github.com/Darwin-River/Robotics/commit/17830275497340bc77ac449e6d0e8875706c91f1).

Now I just need to update the script so that it responds to a sound of a certain volume.

darozak commented 1 year ago

All done. The listen routine switches over to race mode when it hears a sound that exceeds a threshold (https://github.com/Darwin-River/Robotics/commit/19867c37b86dec580afaea59af3d02117b8c993d).