| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.

View
 

Wang_Tien-Sheng_Lab6

Page history last edited by zahraa@... 4 years, 11 months ago

Barebones MP3 Player

 

Part A. Audio Jack

 

Part B. Connect And Test Your Decoder

Describe the tone pattern you hear (i.e., high or low, how long, etc.).

     HIGH, HIGH(flat), LOW

     They last 1 second and have 1 second pauses

 

Part C. Play Some Music!

Tell a member of the teaching team what your song is (or better yet, play it for us).

Adiemus plays first

Somewhere Over The Rainbow/What A Wonderful World plays next

Absolutely Cuckoo plays next

Baba Yetu plays last 

 

 

Does this code play all the songs in all the directories of the SD card? If not, which songs does it play? How does it keep from playing the text file?

     The code only plays .WAV and .MP3 files. This was specified in the Utilities part of the code.

     This part of the code looks for only wav and mp3 files to store in the EEPROM as the next file to open.

     Here it is:

 

char i;

 

    for (i = max_name_len - 5; i > 0; i--) {

      if (p.name()[i] == '.') break;

    }

    i++;

 

    // only store mp3 or wav files in eeprom (for now). if you add other file

    // types, you should add their extensions here.

 

    if ((p.name()[i] == 'M' && p.name()[i+1] == 'P' && p.name()[i+2] == '3') ||

        (p.name()[i] == 'W' && p.name()[i+1] == 'A' && p.name()[i+2] == 'V')) {

 

      // store each character of the file name (including the terminate-array

      // character '\0' at position 12) into a byte in the eeprom.

 

      for (char i = 0; i < max_name_len; i++) {

        EEPROM.write(num_songs * max_name_len + i, p.name()[i]);

      }

      num_songs++;

    }

 

 

Change the Song (or Simple_MP3_V2) program to save the current volume setting in your EEPROM, then fetch and set that value during initialization. Note that the first max_num_songs * max_name_len (in this case, 520) bytes of the EEPROM are used to store file names, so don't overwrite those. 

void setup() {

  EEPROM.write(66, mp3_vol);

 

     ....

 

  Mp3.begin(mp3_cs, mp3_dcs, mp3_rst, mp3_dreq);

  Mp3.volume(EEPROM.read(66));

 

 

 

Part D. Pause to Learn About Interrupts

Draw us a quick sketch of what your circuit looks like.

schema

 

What are the pros and cons of using this method?

     This method waits before reading the button. That means that delays are involved in the code. A con of this method is that delays are blocking, and could slow down your code and ruin buffers.

     Some cons of debouncing are that you can have definite button presses. Debouncing is necessary when the amount of presses matters.

 

Now, take what you learned to make an interrupt driven pause function for your Barebones MP3 player!

     I added this to my code for playing and pausing.

 

byte playpausestate = 1;

....

attachInterrupt(1, playpause, CHANGE);

....

void playpause()

{

  playpausestate = !playpausestate;

  if (playpausestate == 1)

  {

    current_state = MP3_PLAY; 

  }

  else

  {

    current_state = PAUSED;

  }

}

 

 

Video (-0.5)?

we will reinstate the 1/2 point if you uploads the video, and sends an email to zahraa@stanford.edu letting us know of the update.

 

 

 

 

 

Comments (1)

xyyue@... said

at 11:38 am on Aug 15, 2015

GREAT

You don't have permission to comment on this page.