Adding sound to your projects is great, there can be several methods to do it. In this post i will show how we can use wtv020-sd module to get this task done. I wont go in detailed description of the module and will keep the post short and to the point. The module can be operated in a number of modes including pushbutton modes but the one we are going for is the 3 wire serial mode. its actually SDA,SCL and reset wires that we use. The module would play back the ad4 files stored on uSD Card. and spk+ and spk- pins can be connected directly to a speaker. More details about the module can be found in the datasheet and the webpage link.
The interface is simple. you only need to connect Supply , DI ,CLK and reset Pins to get it working although you may also connect some other pins also but this is what is really needed to get the module working.
The timing diagrams in the datasheet can be used to write the program. I will share the code I use for this module.
below is the code .
#include #define SCL 4 //serial clock #define SDA 5 //serial data #define RST 3 //audio module reset /*=============================Delay functions starts==========================*/ void delayus(unsigned int usec) // Function to provide time delay in us. { int i,j; for(i=0;i 0; mask >>= 1) { if (value & mask) PORTC|=(1< <sda); else="" portc&="~(1<<sda);" delayus(200);="" portc|="(1<<scl);" }="" delayms(2);="" stop="" bit="" indication="" void="" init_audio()="" {="" reseting="" the="" module="" delayms(100);="" delayms(10);="" delayms(300);="" send_audio(0xfff7);="" to="" set="" maximum="" sound="" <="" pre="">
Here is an example code to play file 0005.ad4 for 5 secs and then stops the file and start playing file 0001.ad4.
main() { DDRC=0b00011100; init_audio(); send_audio(0005); delays(5); send_audio(0xFFFF); //stop playing send_audio(0001); while(1); }
To convert your audio files to AD4 format you can use the tool provided by waytronics. Get the converter and Sample files from the zip file HERE
</sda);>
Could you please post entire code. Because there is missing good chunk of code.
This is an old post. I am not sure if I have the exact file. Let me know the issues that you are facing and I might help to fix them
Thanks for the share!
what will be the design of EVM for atmega 32 microcontroller…. using 16*2 Lcd?…..Do i need to change anything in the code? that u have given?
I have tried this 'code and design' for atmega 32 with LMO16L but it didn't work….. so what should i do??