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

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Rodrigo Ornelas Lab6

Page history last edited by Benjamin Tee 11 years, 8 months ago

Describe the tone pattern you hear (ie, high or low? how long? etc)

3 notes, all of the same length. low, high , middle

Tell a member of the teaching team what your song is (or better yet, play it for us). If you don't know the name, just decipher some of the lyrics.

Song: Dont fall in love with me yet

 

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?

No, only on root directory. It only plays songs (*.mp3) and counts them and skips from one song to the next, after the last one is played, it stops/

Change the 'song' code to save the current volume setting in your EEPROM and 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. 

When the volume is changed, or at turnoff, or even in the loop:

 EEPROM.write(1000, mp3_vol);

At setup

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

  Serial.println("Current vol= ");

  Serial.print(EEPROM.read(1000));

 

 

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


What are the pros and cons of using this method?

Pro- It is a great method for not getting false positives and an unreliable amount of button press detections.

Cons- The delay is idle time in the microcontroller, it uses precious time.


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

 

in setup
 
 attachInterrupt(INT2, pause, CHANGE);
state volatile current_state = DIR_PLAY; 

add function 
    
void pause()
{
  static unsigned long last_interrupt_time = 0;
  unsigned long interrupt_time = millis();
  // If interrupts come faster than 200ms, assume it's a bounce and ignore
  if (interrupt_time - last_interrupt_time > 200)
  {
    if  (current_state == DIR_PLAY)
          {               
               current_state = PAUSED; 

         }         else           {               

               current_state = DIR_PLAY;  

    }   

 

}

 last_interrupt_time = interrupt_time;

}

it works like a charm :)

 

Comments (1)

Benjamin Tee said

at 12:01 am on Aug 21, 2012

-1 no working video of mp3 player

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