PIC Projects
Doorbell with SD / EEPROM
SD FAT16/32 for .bmp
LCD TFT Egg Timer
LCD TFT Oscilloscope
SD Talking Clock
SD Sound Recorder,
    FAT32 wav Player
LED Thermometer

LED Egg Timer
LCD Egg Timer
Frequency Counters
TFT 10MHz
100KHz For PC
1MHz For PC
8 Digits LED 50 MHz
Scope Screen Display
LCD Module 10MHz
6MHz for Android
USB PIC18F2550
USB TFT display BMP
USB DS18B20 Sensor
USB Thermometer
USB Counter
USB Meter
USB Oscilloscope
USB Input-Output
USB 16x2 LCD

COM & LPT Ports
MCP3201 on LPT
Serial TFT Text
Serial Inputs Outputs
Serial Port LCD
Analogue Signal to LPT
MCP3201 on Serial Port
Serial Thermometer
Analogue Signal to Serial
LCD Display on LPT
Serial Thermostat

Others
Water Softener
HP Stream 7 docking
3.7V to 5V
Solar Charger

Infrared Decoder
PIC Music

Code Lock
Code Lock with LCD
HOME MOBILE Technical Tips

ARDUINO SD DOORBELL

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).

Troubleshooting:
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 limitations.

ARDUINO EEPROM DOORBELL

A doorbell project for Arduino Uno with ATMEGA328P device.
The EEPROM 24C512 is 512Kbits and it can store up to 3 seconds wave file of  22.050KHz, 8 bits, mono.
The Arduino reads the ROM bytes in a sequential read mode and stream each byte to the PWM generator at a rate of about 22 KHz. The I2C bus works at 200 KHz for the purpose of managing to process 22 Kbits per second. Changing the bus frequency changes the speed of the sound.
The I2C lib doesn't have a function for sequential read, so I added a routine. 
Included in the software is HEX file for the EEPROM. It has a sound of a rooster crowing, I use this one in my house.

To convert sound file to hex do this:
Convert sound file to .wav PCM  22.050KHz, 8 bits, mono
Change the file name extension from wav to bin.
Load the bin file to the EEPROM Programmer, I used PICKIT2.
To remove the file header you can change the first 44 bytes to zeros or remove them using any BIN FILE EDIT software.
Export the file from the programmer as HEX.      

PIC16F876A EEPROM DOORBELL

The EEPROM 24C512 is 512Kbits and it can store up to 3 seconds wave file of  22.050KHz, 8 bits, mono.
The PIC reads the ROM address 0 first and then reads bytes in a sequential read mode and stream each byte to the PWM generator at a rate of about 22 KHz. The I2C bus works at about 300 KHz for the purpose of managing to process 22 Kbits per second. Changing the bus frequency changes the speed of the sound.
I use resistors DAC (Digital to Analogue Converter) because the PIC's PWM is too slow.
It is easy to get 6 seconds sound at 11.025 KHz wave file by changing the crystal osc to 4 MHz.
Included in the software is HEX file for the EEPROM. It has a sound of a rooster crowing, I use this one in my house.

To convert sound file to hex do this:
Convert sound file to .wav PCM  22.050KHz, 8 bits, mono
Change the file name extension from wav to bin.
Load the bin file to the EEPROM Programmer, I used PICKIT2.
To remove the file header you can change the first 44 bytes to zeros or remove them using any BIN FILE EDIT software.
Export the file from the programmer as HEX.

Circuit Description
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.

Circuit Description
See also Technical Tips

BC337 switch on the audio amp for the duration of the ring.
Vin can be up to 15V.
pin 7 of 24C512 can be connected to 5V to inhibit writing.

 

Circuit Description
See also Technical Tips

BC337 and BC307 switch on the audio amp for the duration of the ring. You can omit this switch and connect the amp directly to the supply if the hiss noise from the amp isn't a problem.
Audio amp can be replaced by any amp.
pin 7 of 24C512 can be connected to 5V to inhibit writing.
1R resistors can be 10K or 7.5K and 2R 20K or 15K. Values aren't critical, 20% error is acceptable.





Name:

Comments and questions

Copy the number from the picture It stops net-robots from adding comments.



15.06.2017 - 14:08
Name: Moty
Comment: It is easier to learn how to use FAT32 from a tutorial, my code gives too little information. The first 11 bytes of the 32 bytes File Descriptor are the file name, you have to read them. The bytes are in string data type.

14.06.2017 - 16:02
Name: flexo
Comment: hi moty say i have 3 wav(1.wav,2.wav and 3.wav) files and i want to select a particular file say 2.wav how do i adjust the code.

14.06.2017 - 15:42
Name: djalltra
Comment: i love the way you make your codes short but i still have troubles understanding the fat32 file system

14.06.2017 - 15:37
Name: Djalltra
Comment: another new project cool