Player wav files on the Attiny85 microcontroller

In this article, we will consider the process of creating a very necessary and interesting electronic device that will allow you to play wav format files directly from an SD, microSD or mini SD memory card. You can record a music file on a memory card, install such a device, for example, in a refrigerator, and each time you open its door a beautiful melody will sound. Forgetting to close such a “musical” refrigerator will no longer be possible. Another option for using the player is as a doorbell. On the Internet you can find many different tunes, for every taste. Thus, the boring sound of a factory call can be replaced, for example, with a song you like. In addition, such a device can be used for an original gift for a loved one - it is enough to integrate the speaker into a beautiful box, when you open it, a sound greeting will start to sound. In addition to these examples, the player can find a lot of applications in everyday life.

Player circuit

The device diagram contains a minimum of details, its key link is the microcontroller of the AVR Attiny85 family. When power is applied, it immediately begins to read files from the memory card and use the PWM outputs to play them through the speaker. The volume in this case is not too high, in many respects it depends on the sensitivity of the speaker used. To get a high volume, you need to connect the amplifier input instead of the speaker. However, the signal from the output of the microcontroller is too large to supply directly to the amplifier, so it is imperative to set the volume control between them, otherwise there is a risk of spoiling the amplifier itself. When you turn it on for the first time, you need to set it to the minimum volume position, and then gradually increase it until the desired volume level is reached.

Memory card pinout

The pinout of memory cards is shown in the picture:

6 wiring, two of which are power, the circuit is connected to a memory card. You can use both SD and MicroSD and MiniSD, the main thing is to keep the correct pinout. It is most convenient to use an unnecessary MicroSD adapter in SD, then it will be possible to solder the wiring to the adapter itself, into which the used memory card is already inserted, I did just that. Before using in this scheme, the memory card must be formatted in the FAT file system. After formatting, you can write wav files to the card; they must be in PCM format 8 or 16 bits, with a sampling frequency of not more than 48 kHz. There are many computer programs that allow you to convert ordinary mp3 files to wav format, one of them is GoldWave, I used it.

When you connect the power or insert a memory card, the circuit will begin playback, when you click on the button, the next file is included. Memory cards require 3.3 volts, so the stabilizer 78L33 is installed on the printed circuit board proposed for the article (it is not indicated on the diagram). Using a stabilizer, the supply voltage of the circuit lies in the range of 5-12 volts. This circuit consumes a small current, and therefore it can be powered by a battery. To do this, you need to take a boost converter 3.7 - 5 volts, as I did.

The circuit starts working immediately, does not require any configuration, it is enough to flash the microcontroller. The fuse bits must be set as shown in the picture below (a check mark means that this bit is programmed, as in PonyProg).

You can download the board and firmware here: [11.88 Kb] (downloads: 284)

The fee of the assembled player

Photo of the player I collected:

Converter for power.