Feliz Navidad learners! Christmas is just around the corner. What better way to welcome our guests than a fine Christmas song? In this beginner friendly tutorial, I’ll teach you how I made an automated door greeting device using a magnetic reed switch, a digital speaker module, and an Arduino UNO.
What you’ll need:
- Arduino UNO
- Magnetic reed switch
- Digital Speaker Module
- 2 LEDs
- 2 x 220? resistors
- 1 x 10k? resistor
Magnetic Reed Switches
For us to understand how magnetic reed switches work, we will follow this guide from randomnerdtutorials. First, using a breadboard, build the schematic diagram below.

Basically, what this circuit will do is it will light up the yellow LED when the reed switch is together and light up the red LED when it is separated. Upload the code below to see for yourself!
You can put your LED and reed switch pins on any GPIO pins on the Arduino. Just be sure to define them correctly in your own program.


Now let’s add the digital speaker module into our switch mechanism. Just like the LEDs, you can insert the speaker into any GPIO pins you want, just indicate where you’ve put it in the program.

To test the speaker, copy the code below and upload it into your Arduino.
You should hear a constant 1kHz sound from the speaker. To test further, let’s send 1kHz signal pulses by adding a delay.
You’ll hear a sound akin to an alarm. Doesn’t this give you an idea on where we can use this? Congratulations! Yes, you’ve just made the simplest door alarm security system in history! Try attaching the whole system on your door.


Power Supply
Of course, to make this work you’ll need a small power bank or power supply of some sort. In my case, I made a rechargeable and current-adjustable power supply using a 18650 battery, a used TP4056 charging board and a MT3608 step up converter. I don’t advise doing this but if you, by chance, have this boards lying on a box somewhere, you’re most welcome to do this as well.

Making the Speakers Sing
To make the digital speaker play a tune, we’ll assign all the frequencies of all notes possible using this code:
You can add that before your main program but in order to make everything a tad tidier, I followed this guide. Basically, I made my own header file “pitches.h” defining all this constants. Now all I have to do is call it in the program. With that, we’re all set up to compose our Christmas song. I choosed, “We Wish You a Merry Christmas”, because I feel it welcomes guests a little bit better then “I Saw Mommy Kissing Santa Claus”. I used this as a reference for the song.
Here’s the whole code for the main program:
That’s it! Only thing left to do is preparing how to answer your guests asking how this device wplays a christmas song every time they come in. Again, stay tuned on Learn for fun projects like this. I did an analysis on the basic arduino schematic diagram previously, you might want to check it out. Merry Christmas, and keep creating!