A doorbell project for Arduino Uno with ATMEGA328P device.
The firmware works for SD or SDHC cards only. Do not use SDXC cards with this project because some of them work on 1.8V drive. The code detects whether the card is SD or SDHC and selects the proper addressing system for the card. The quality of the audio is reasonable.
The software has the functions needed to read SD/SDHC card formatted in FAT32. The software can play only PCM 22.050KHz, 8 bits, mono. The bytes from the file are streamed to PWM
generator and with an external low pass filter you get the audio. The PWM
gives 64KHz wave with duty cycle modulated to the audio amplitude. A low
pass filter removes the 64KHz component.
SD card interfaces the microcontroller in SPI mode. Reading data is in multi-blocks.
The Error LED indicates error of communication with the SD card.
The software searches for files entries in the root directory only, it streams any file type without reading its name or type.
TO SET UP THE CARD:
Create sound file type .wav
Name the file with short name, 8 low case characters max.
Save the file as 22.050KHz, 8 bits, mono.
Format the card with FAT32.
Add the files to the root directory
of the card (don't use a subdirectory).
If the Error LED is on immediately on power up it means that the card
failed to initialize. This code works for SD card rev 2 or SDHC card, it
doesn't work for SDXC (1.8V) or MMC or SD rev 1 cards.
More about FAT32 in this document: https://staff.washington.edu/dittrich/misc/fatgen103.pdf
More about WAV in here: https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
Good free specifications for SD can be found in SanDisk PDF: http://alumni.cs.ucr.edu/~amitra/sdcard/ProdManualSDCardv1.9.pdf
Arduino code. You are free to use the circuit diagram and software with no
See also Technical Tips
The 3.3V is sourced by the Arduino board.
1K and 2K resistors at the inputs to the SD are to reduce the 5V signals to 3.3V signals. MISO card output is only 3.3V but it is ok for the 5V input of the AMD.
The card's pins number are for standard size SD, for Micro SD the pins are different.
BC337 and BC307 switch the supply to the audio amp while audio output is on.
The circuit diagram includes a battery operated bell. A
CMOS 4011B is used to switch the battery on when the pushbutton is pressed
and switch it off by a signal from the Arduino. This ensures only 1 uA
drain from the battery at standby.