3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.


Music Playing Alarm Clock

Music Playing Alarm Clock
 


This Instructable will be about designing a music player from using various building blocks. You will understand the communication between the microcontroller, memory, computer, LCD display, RTC, IR remote, and the music file decoder. I will try my best to to teach you in a way so that you can design your own projects using the skills you learn, without blindly following instructions.

I know most of you will simply glance at this first page and maybe skim through the rest. This Instructable has 18 steps and 5 appendices, with about 90 files and pictures. I sincerely hope you explore all my efforts.

Every step will be accompanied by a demonstration of that particular building block working. The source code will be provided. I will post the debug output, pictures, screenshots, USB device and packet analysis, and logic analyzer waveforms. NOTE: if the images look too compressed, don't worry, they are included inside my .ZIP files too.

To start off the project, set your goals. This will be a simple proof-of-concept music player. It will allow the user to load music as through USB as though it is a mass storage device, display the current song to the user, display the current time, set custom alarms for every day of the week, and allow the user to control it through a remote control. To accomplish these goals, you need:

* USB capable microcontroller
* LCD display
* Storage
* Sound output
* IR receiver and remote control (any)

This is the obvious overview, however, we also need a RTC (real time clock) to keep track of time using a backup battery, just in case the power goes out.

Note that with my collection of supplies, budget, and skills, I've decided to use a VS1033D decoder IC from VLSI Solutions, which integrates music file decoding and digital-to-analog output. So the item "sound output" in the above list expands into "decoder" and "speaker"

I will be using the following components during this Instructable (this is not a full part list, not even close, but these are major):

AT90USB1286 microcontroller (on a Teensy++ http://www.pjrc.com/store/teensypp.html ), datasheet is here: http://www.atmel.com/dyn/products/product_card.asp?part_id=3874
VS1033D music decoder http://www.vlsi.fi/en/products/vs1033.html on a breakout board http://www.sparkfun.com/products/8792
16x2 character LCD display, ST7066/HD44780 compatible, using 3.3V instead of 5V
DS1307 real time clock

Note that the entire circuit will run off 3.3V, if you are buying a Teensy or Teensy++, please buy http://www.pjrc.com/store/mcp1825.html and follow the correct procedures to solder it and use it (it involves a jumper). Please also note that you must also run the Teensy at 8 MHz instead of 16 MHz because of the reduced voltage.

I also hope that once you are done, you'll be able to apply the skills you learn here with other microcontrollers and devices.
 
Remove these adsRemove these ads by Signing Up
 

Step 1Before You Begin

Before You Begin
Instead of giving you the whole schematics and source code and tell you to build the damn thing while showing pretty pictures, I will break down the building blocks of this project, and give you demonstrations of that particular "block" that you should perform in order to understand what is going on. Through this process you will learn how to diagnose problems and also how to use various techniques in other projects.

To get you started, I will make sure you know how to compile and upload a "hello world" program to the Teensy++. This code will show you how to output debug messages, which will be useful later.

Obviously you need an AT90USB1286 microcontroller for this, and since it's hard to solder by hand, I choose to buy a Teensy++. http://www.pjrc.com/store/teensypp.html

This example is based on "USB Serial" on PJRC
http://www.pjrc.com/teensy/usb_serial.html

If you wish to learn more about communication with USB, please refer to my appendix "step" about USB.

Please refer to my appendix "step" about AVRs to figure out how to use makefiles and the GNU AVR toolchain.

Download the files attached. Run "make" to generate the .hex file. Upload the .hex file to the microcontroller. Open up a serial terminal to see the output. The baud rate shouldn't matter since this is a fake serial port.

Provided below is the USB analyzer dump of the device and a sample packet of data, for those of you who wish to learn more about USB.

Note: I personally REALLY like using RealTerm as a serial terminal http://realterm.sourceforge.net/ , I will be posting screenshots of the terminal output whenever I can. I will also post logic analyzer screenshots, .logicsession files (can be opened with the Saleae Logic software http://www.saleae.com/logic/ ), and exported files whenever I can.

Some people have asked me about how to use stdio.h and printf (and similar streaming and formatting functions) on AVR microcontrollers, the following links are in the code comments:
http://www.nongnu.org/avr-libc/user-manual/modules.html
http://www.nongnu.org/avr-libc/user-manual/group__avr__stdio.html

Also since this is "before you begin", go download Saleae Logic's software, if I ever attach .logicdata files, you need the software to view it. http://www.saleae.com/logic/ , it's in the downloads (version 1.1.14 is what I used) page, you can use it even if you do not own a Saleae logic analyzer. I will also try to include screenshots.
« Previous StepDownload PDFView All StepsNext Step »
67 comments
1-40 of 67next »
Feb 27, 2012. 12:00 PMchrwei says:
what's the highest bitrate mp3 you've been able to smoothly play on this?
Feb 27, 2012. 1:12 PMchrwei says:
but have you tested? There's theory and math, and then there's actual real world performance. Sometimes real world is better than the math, especially when dealing with human perception, and sometimes it's far worse.
Feb 27, 2012. 11:54 AMchrwei says:
Sparkfun seems to have fixed their VS1033D breakout board now, so hopefully Step16 is no longer needed for new builds
Feb 13, 2012. 3:29 PMwoow says:
Hey, sorry for bothering you again:(
i am currently using a mbed to program the alarm clock, and I have successfully decode one song from sd card. Just wondering how can you decode the name of the song so the mbed can decode any song that I put in through USB. Currently I am using code like ' fopen("/sd/mp3/test1.mp3","rb");' so the title of the song must be test1. Thank you very much:)

Jan 19, 2012. 4:06 AMankush_karche says:
Hello, I have purchased all parts for this kit and progressing on it. For IR Code Capture I am getting problem and stuck since very long time. Even for £1 valued IR diode I have spent £16 and for remote controls I have spent £40. I would appreciate if any body can guide me for Remote Control. Where can I get intented remote control (make / web link).

Please help. Your help is highly appreciated.

Best regards,
Ankush
Jan 20, 2012. 10:35 AMankush_karche says:
Hello Frank,

I am using codes given by my remote controls in IRCodeInterpret module but not matching with and just displaying message Checking .... on Realterm.

As described by you, remote control should display same pattern that's what not happening.

Any other ways to overcome this problem ?

Please help.

Best Regards,
Ankush
Jan 20, 2012. 1:02 AMankush_karche says:
Hi Frank,

Thanks for your response. I am getting codes with IRCodeCapture module but each time for same button pressed on remote control codes displayed are different.

I put these codes in IRCodeInterpret module and check it. I get output on RealTerm screen as checking..

When I put ircodes in header file and check interpret module then I should get which button is pressed on remote control. But it is not showing due to codes not matching.

Hope the problem is resolved with your help.

Regards,
Ankush

Nov 25, 2011. 2:59 AMxp309 says:
Great project! really helps a lot. I just got couple of questions wanna ask you about. Firstly if i decided to use an arm micro-controller, i would not need to use a music decoder right? Instead I need a DAC?
Secondly, how do u decide what size of RAM and frequency u need]?
Thirdly, is sd card originated formatted in fat16 and what does fatfs do exactly (the difference between it and fat16) ?
Lastly,why do you choose ADR instead of ARM? Is 8 bits AVR gonna be fast enough for playing mp3 file?
Cheers and look forward to hear from u



Nov 26, 2011. 5:22 PMxp309 says:
Thank you so much for the answer. I am trying to calculate the mp3 bit rate which is 100kbps (3mb/(5min x 60)) .however how do I relate it to the frequency of the microcontroller?

Nov 27, 2011. 6:12 AMxp309 says:
thanks for the answer.,i think i wrote my question in the wrong way..i wanted to ask how do you calculate the minimum and maximum frequency that you need to have for the microcontroller
Nov 10, 2011. 10:27 PMwoow says:
hey.sorry to bother u again.can i use vs1003b instead of vs1033d as the only difference is the i2s interface? And the I2S interface for external DAC function is not used in this case right?
Thanks :)
Nov 10, 2011. 7:16 PMwoow says:
So do that that mean if i wanna use a loudspeaker, then i must use the audio decoder with I2S interface? Thanks :)
Nov 13, 2011. 5:51 PMwoow says:
sorry...i didn't quite understand..so i can use vs1003b connect to speaker but i need an amplifier to make the music sounds louder right? also, if i am now using sd card only, like what u did at the end, do i still need file system? thanks a lot :)
Nov 10, 2011. 5:58 PMwoow says:
helllooo..thanks for this!
can i ask what other micro-controller and music decoder that i can use which would have the same functions but cheaper? Many thanks :)
Nov 25, 2011. 4:18 AMwoow says:
sorry for so many questions....i am really a beginner in this field..may i ask why you need music decoder for your design? i saw online that avr has mad library that could use to decode mp3. and also arm has the libmad library to decode the music without music decoder right?
Nov 20, 2011. 7:28 AMwoow says:
hey.i have decided to use a mbed.. however from my research, you still need a music decoder to go with it? also i couldn't get how sd card communicate with usb host and usb host with pc using mbed.thanks :)
Nov 7, 2011. 11:49 AMolegmilosevic says:
where to find teensy board ???
Sep 15, 2011. 9:42 AMdiskincluded says:
Is there a way to make the alarm start with a very low volume, then build up to regular volume over a few minutes?
Sep 15, 2011. 11:07 AMdiskincluded says:
Well then, it would appear I have some parts to buy.
Aug 17, 2011. 12:31 PMldaturtle says:
Hey, Great project! All the parts I need just came in the mail so I have begun building this alarm clock. However, this is my first electronics project (so i'm pretty noob at it) and I am stuck trying to setup realterm correctly.. I uploaded the hex file to the microcontroller, and I have realterm installed and running. But how do you setup realterm to get it to read the data the microcontroller is sending?
Aug 17, 2011. 3:40 PMldaturtle says:
I am using the Teensy++, I have everything setup correctly I believe.. But when I click start: overwrite or append, nothing happens. I have the capture file setup as well but it doesn't capture anything..
Aug 17, 2011. 7:19 PMldaturtle says:
perfect, thanks
Jul 27, 2011. 12:56 PMRobotics Guy says:
Very cool project! I wrote a very in-depth tutorial on the hd44780 and thought you might want to add it to your LCD Basics section: http://www.robotenthusiasts.com/page/index.html/_/tutorials/pic-microcontrollers/hd44780-lcd-r14
Jul 8, 2011. 11:54 AMudawatabhimanyu4 says:
hey, you seem to have done Ph.D in Teensy...
1-40 of 67next »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
176
Followers
12
Author:frank26080115(Frank's Projects)
I'm an electrical engineering student at the University of Waterloo.