Electronic Deer Whistle – ElectroSchematics.com

A deer horn, or deer whistle, is a whistle mounted on automobiles to help prevent collisions with deer. Air moving through the device produces sound to warn deer of a vehicle’s approach, usually when the vehicle exceeds 30 mph. If the whistle gives them advance warning, they may freeze on the roadside, rather than running across the road into the path of the vehicle. Vehicle mounted (wind-activated) mechanical deer whistles/horns are probably one of the most popular auditory deterrents!

Invented in Austria in 1979, deer whistles are still distributed by many companies in Europe and the United States. For deer whistles to be effective, the sound should carry as far ahead and to the sides of a vehicle as possible, so that deer have time to react. Fortunately, simple air-activated whistles are relatively cheap and easy to install. Once mounted to the front bumper or grill of a vehicle, they are supposed to emit an audible (sometimes ultrasonic) sound that alerts deer and scares them off.

The deer whistle project presented here is not like those conventional air-actuated deer whistles. Adaptable design of the electronic deer whistle, easily attachable to car/bike bumpers, is centered on a small microcontroller. The ‘sonic’ sound of this electronic deer whistle does not scare the deer off the road but makes them aware that something is approaching. There have been a lot of questions about whether the deer whistles work, however it is hoped that the whitetail would react to this acoustic attention-getter by remaining still.

Since I had not used a deer whistle before this project, I was not sure how to make my own electronic version of a compact deer whistle/horn. Doing a bit of research, I found that tests conducted by University of Georgia researcher Gino D’Angelo pointed out that deer can effectively hear within the range of 250 Hz to 30 kHz, and their best sensitivity is between 4 kHz and 8 kHz. Apparently, some commercially available electronic deer whistles have 3.5 kHz to 5.5 kHz frequency range because it’s presumed that most effective hearing range of the whitetail deer, the most common species in the United States, is between 2 kHz and 6 kHz.

For this project I am using a Chinese clone of the Digispark Attiny85 microcontroller board. The Digispark is configured to deliver a 3500Hz tone (100ms on – 100ms off) through one I/O pin (P1-SP).

As you can see, there is also an auxiliary output channel (P2-LED) for driving one or more external LEDs. A switch input (P0) is provided to enable low-voltage remote switching of the device. That means you can mount the device on the front bumper and power it through an ignition switch controlled 12VDC power supply wire. Since the Digispark board has an onboard linear voltage regulator, there is no need to use an external adapter (voltage converter or regulator) between the circuitry and the large car battery.

And then, you can switch the device on/off through a small momentary (or toggle) switch mounted on the dashboard. Only a low voltage cabling scheme is required for that setup because the switch input is just a low current I/O (P0-SW) of the microcontroller running on regulated 5VDC. If you do not want the remote switch option, simply make a bridge across the pads of the associated solder jumper (SJ).

This is the refactored code for Digispark board (Able to run on Arduino Uno/Nano too). You can change the base frequency to cope with your actual requirement – ​​sonic or ultrasonic whistle!


int triggerPin = 0; // Digispark P0 = Switch Input

//int triggerPin = 12; // Uno or Nano

int piezoDrive = 1; // Digispark P1 = Tone Output

//int piezoDrive = 10; // Uno or Nano

int lampDrive = 2; // Digispark P2 = LED Output

//int lampDrive = 13; // Uno or Nano

int val = 0;

void setup() {

  pinMode(lampDrive, OUTPUT); // P2 = Output Pin

  pinMode(triggerPin, INPUT_PULLUP); // P0 = Input Pin (with Internal Pull-Up)

  pinMode(piezoDrive, OUTPUT); // P1 = Output Pin


void loop() {

  val = digitalRead(triggerPin); // Read Switch Status

  if (val == LOW) {

    digitalWrite(lampDrive, HIGH); // LED On

    playTone(100, 3500); // Fout = 3500 Hz

    delay(100); // 100ms

  } else {

    digitalWrite(lampDrive, LOW); // LED Off

    playTone(0, 0); // No tone

    delay(300); // 300ms



void playTone(long duration, int freq) {

  duration *= 1000;

  int period = (1.0 / freq) * 1000000;

  long elapsed_time = 0;

  while (elapsed_time < duration) {

    digitalWrite(piezoDrive, HIGH);

    delayMicroseconds(period / 2);

    digitalWrite(piezoDrive, LOW);

    delayMicroseconds(period / 2);

    elapsed_time += (period);




This is the waveform caught by my oscilloscope when it is probed across the 2-pin tone output connector (SP). As mentioned before, the simple code delivers a ~3.5kHz tone for 100ms, pauses 100ms and repeats (look, the period is divided by two). This is assuming a complex/alternating whistling tone would be better than a ‘pure’ tone!

The Sounder Challenge!

As far as I know, academics have not been impressed with deer whistle performance! Although deer have extremely sensitive hearing some researchers have pointed out that the challenges of producing sound at an appropriate frequency (and intensity) from a moving vehicle, deer whistles/horns do not appear to be suitable for deer-vehicle collisions. In summary, there is no firm evidence that deer whistles are effective and considerable evidence that they are not!

Deer and automobiles never share their ways graciously or safely. I would like to leap into the next part of my deer whistle design presuming deer can hear and will be alert away from noise generated by my deer whistle. On to the hard part of the design – the sounder circuitry!

A typical commercial electronic deer whistles/horn offers an 89dB output (https://www.iacacoustics.com/blog-full/comparative-examples-of-noise-levels.html). One modest approach is to setup a standard piezoceramic disc/piezoelectric element as the ‘loudspeaker’ of the deer whistle/horn. In this way, the piezo device can act as a mighty loudspeaker to produce frequencies over a specific bandwidth, thus the tone generated by the microcontroller can be rendered aloud. For my prototype I used a small-signal transistor to drive the piezo disc as follows.

Role of the inductor (L1): A square wave will produce higher sound levels because of the near instantaneous rise and fall time. However, it is also possible to increase the SPL of a piezo sounder by about 3 to 6dB using an appropriate inductor (booster coil). The higher SPL is a result of the resonance between the inductor and the element, which is capacitive. Generally, the most common ‘practical’ inductance value is between 10mH and 100mH.

Remember that a piezoelectric element alone cannot produce a high sound pressure level (SPL). This is because the acoustical impedance of the piezoelectric element does not match that of any open-air loading. Therefore, a resonating cavity must be built to match the acoustical impedance of the piezo element and the encased air (perhaps good theme for a future post).

All over schematic of the electronic deer whistle/horn (v1):

Now let’s get down to work with the external LEDs. As clearly depicted in the final schematic, there is a small-signal transistor (T2) wired between the LED drive output (P2-LED) of Digispark and the external LED connector (EXT_LED). I am going to use a bunch of blue LEDs in my prototype (of course with series resistors).

Why blue light? Recent research into whitetail vision (https://www.uga.edu/) confirms that the whitetail’s eyes are most sensitive to colors in the blue-spectrum ie the light that’s most available at dusk and dawn when they’re most active. Furthermore, the greatest amount of light reflected by the underside of a deer’s tail is in the blue-spectrum. When deer flee threats with their whitetail flagging, they are waving powerful visual cues to other deer!

The last piece of the puzzle is the design of the deer whistle enclosure. Here is how I plan to make it work. See the inspired artwork below.

Remember, by designing the piezo diaphragm and the cavity to have the same resonant frequency, the SPL is maximized, and specific bandwidths can be provided. The resonant frequency of the cavity is obtained from Helmholtz’s Formula:

Bonus: 40kHz Square wave with Arduino Uno!!

As some already did, the following simple piece of code can be used with an Arduino Uno to generate a 40kHz square wave (50% duty cycle) signal at its PWM Pin 6. See below table (Compare Output Mode, Fast PWM):

Let’s not make things more complex, but in fast PWM mode one of two pins (Pin 6) on Timer 0 is able to generate 50% duty cycle signal with a frequency we can alter (Timer 0 manage pins 5 and 6, and on Timer 1 the pin is 9 while on Timer 2 it’s pin 11). In Fast PWM mode, timer counts from a BOTTOM value to a TOP value after that it overflows to BOTTOM value and iterates. To choose the fast pwm mode in the TCCR0A we must make the WGM01 and WGM00 bits equals 1.

In the below code we have TCCR0A=B10100011, means that the WGM00 and WGM01 from the TCCR0A register are 1, so the pins 5 and 6 are in the fast PWM mode. And, since OCR0A is 199 (and no prescaler) the output frequency, from formula fOCR0A -=fclk/2N(1+OCR0A), is 40kHz. For more details, read Atmel ATmega328/P datasheet thoroughly.


/* 40kHz square wave in fast PWM mode :: Pin 6 */

void setup() {

pinMode(5, OUTPUT);


TCCR0A=0;//Reset the register

TCCR0B=0;//Reset the register

TCCR0A=0b01010011;//Fast PWM mode

TCCR0B=0b00001001;//No Prescaler and WGM02 is 1

OCR0A=199;//Control value for 40kHz from the formula


void loop() {

// put your main code here, to run repeatedly



See the resultant oscillogram:

Finally, my electronic deer whistle/horn project has not passed the breadboard stage yet. I dream more than do, but I expend much of my life realizing those dreams!

As you can now see, I rigged up a quick breadboard setup (3.5kHz version) and ran some tests with one small car dome tweeter I had on hand. Another trickery I made in the quick setup was the replacement of the external LED driver circuitry by a single 5mm blue LED (and its series resistor) as it is enough for quick debugging. The “5-20kHz” car dome tweeter (used in lieu of the piezo-disc and inductor combination) has a rated impedance of 4Ω (and approx. 30uH inductance).

This is the inside view of that car dome tweeter comprised a small piezo-disc and a big booster coil.

Do you have feedback or questions on this project? Then please write a comment!

Credits & References

Leave a Comment