Why Do We Have Two Ears? Directional Hearing With Two Microphones & Arduino

by stoppi71 in Circuits > Arduino

2108 Views, 23 Favorites, 0 Comments

Why Do We Have Two Ears? Directional Hearing With Two Microphones & Arduino

Richtungshören_Arduino_54.jpg
Richtungshören_Arduino_32.jpg
Richtungshören_Arduino_10.jpg

Why do humans actually have two ears? Well, you might think that it sounds a lot better with two ears than with just one ear. That's true, but there is another reason we have two ears rather than just a single one.

The reason is as follows: The direction of the sound source can be determined with two ears. Let's assume the sound source is to the left of the center. Sound waves now emanate from the sound source in all directions. However, these sound waves now arrive at the left ear a little earlier than at the right ear. The brain can now determine the direction from this time delay. Awesome, isn't it? And our brain does this without any action on our part.

What does the mathematical model for directional hearing look like? This is very simple and only consists of a single trigonometric function, namely the sine or arc sine. The brain perceives a time delay delta_t. Accordingly, the additional distance covered by the sound was delta_t * speed of sound v. We also know the distance d between the two ears. With this and the distance difference v * delta_t, the angle alpha results from which the sound comes with the formula: alpha = arcsine (v * delta_t / d) It doesn't get any more complicated ...

The Arduino Part

Richtungshören_Arduino_28.jpg
Richtungshören_Arduino_53.jpg
Richtungshören_Arduino_49.jpg
Richtungshören_Arduino_34.jpg
Richtungshören_Arduino_08.jpg
Richtungshören_Arduino_12.jpg
Richtungshören_Arduino_31.jpg
Richtungshören_Arduino_14.jpg
Richtungshören_Arduino_20.jpg
Richtungshören_Arduino_29.jpg
Richtungshören_Arduino_40.jpg
Richtungshören_Arduino_46.jpg
Richtungshören_Arduino_42.jpg
Richtungshören_Arduino_44.jpg
Richtungshören_Arduino_48.jpg

For this project we only need a case, an Arduino Nano, two sound modules Ky-038 and a small servo motor SG90.
If the servo needs too much current, it must not be connected to the 5V pin of the Arduino, but must instead reduce the 9V from the battery to 5V using the 7805 voltage regulator and then supply the servo with it.

The two sound modules have an analogue and a digital output. At the analog output there is a voltage proportional to the volume. The digital output is either low (0V) or high (5V), depending on whether the volume has exceeded a certain threshold or not. This threshold is set with the potentiometer on the sound module. Of course, both thresholds must be set the same for this project. To do this, you clap your hands in front of the microphones and both sound modules have to respond to the clap in the same way. You can see this on the LED, which is located on the sound module.

The digital output of the two sound modules is now connected to pins D2 and D3 of the Arduino. If the digital signal changes from low to high, it triggers a so-called interrupt in the program. If this is triggered, the program notes the time of the interrupt. There are then two times t1 and t2 for the respective microphone. The time delay delta_t = t1 - t2, which is required to determine the direction of the sound source, can be calculated from these two times.

But there is a small blemish. The digital output always goes high when, as I said, the volume is above the set threshold. If I clap my hands, the volume exceeds this threshold several times in quick succession. This can be seen very well on the oscilloscope (see illustration). Now the program would save the times several times and possibly calculate a wrong direction from them. However, the program should only react to the first time the threshold is exceeded. For this reason I ask in the interrupt what time has passed since the last interrupt. The interrupt is only evaluated and the time is saved if this elapsed time is greater than a certain value.

However, if the last interrupt was too short a time ago, the interrupt is not evaluated and the time is not saved. The time delay between the two signals can also be seen very well on the oscilloscope. The signal at pin digital-out 2 starts a little later than that at pin digital-out 1 of the first sound module (see illustration). It is precisely this time delay that is recorded by the software.

Code & Conclusion

Why do we have two ears? Directional hearing with two microphones & Arduino - Richtungshoeren

This project is really very simple and you can therefore implement it for teaching without any problems. The students will certainly enjoy clapping from different directions and seeing whether the device has recognized the direction. The total costs are not even 20 euros. Nevertheless, it is a very good object for teaching physics or biology.

If you want to see my other exciting physics projects, here is the link to my homepage or to my youtube channel:

my youtube-channel

my homepage

I would be happy if you also implement this project. In this sense, good luck and Eureka