Cheer With Me! A Grove Sensor Adapter project
The NXT sound sensor enabled some fun projects. Unfortunately it has retired, and the sound sensor has not made a return with the EV3. However, the mindsensors Grove Sensor Adapter has you covered! The Grove sound sensor attaches just as easily as any other Grove sensors, here's an example.
The Grove Sensor Adapter is mounted to the side of the EV3 and connected to sensor port 1. The Grove sound sensor is mounted to EV3 as well, and connected to the other end of the Grove Sensor Adapter. What does this project do? Take a look!
When it detects a clap, the program will cheer along with you! Let's take a look at the simple program.
First it repeatedly reads the Grove sensor until it gets a valid reading. If the sensor is not connected, it will keep checking until it is. Then it compares it too 800, which we found is a good level for indicating a clap. A clap will show the clapping emoji and a cheering sound.
If you want to get a bit more out of it, you can count the number of claps and act accordingly. The example program is available at the end of this article, but we'll take a quick look at the program.
This program is a bit more complicated because it has to distinguish between a repeated clap and a new clap sequence. As before, it waits for a clap. When there is a clap, it adds one to the clap count variable. To make sure it doesn't count the same clap as multiple, it waits for the clap to end. At the end it displays the number on screen.
The last aspect of this program is the timer. Whenever there is a clap, the timer is reset. If the timer ever gets past one second, it determines that you have stopped clapping and sets clap count to zero. This is when you could take action, such as playing a number of notes or moving your robot in a certain way.
Make some noise for the Grove sound sensor!
Addendum
One of our customers, Allen M., has extended this project. If you do still have an NXT Sound Sensor, he has adapted this program to work with it. Further, he comments "I modified the second one to count the claps and then do something based on the number of claps." Thank you, Allen, for submitting your project, other readers can download it here.