| 
  • 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
 

Mutkoski Michael Lab 6

Page history last edited by xinyi xie 9 years, 8 months ago

Part B. Connect And Test Your Decoder  

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

There are three tones being played over and over with one second intervals between each one. Each of the tones is a second long as well. The pattern of the three notes is HIGH MEDIUM LOW.

Part C. Play Some Music!

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

The first song is Absolutely Cuckoo by Magnetic Field, then Baba Yetu by Christopher Tin, then Adiemus by Adiemus, then finally What a Wonderful World by Israel Kamakawiwo'ole.

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?

It plays the songs on the SD card with the file extension mp3 and wav. The other files on the SD card it ignores.

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

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

int vol = EEPROM.read(max_num_songs * max_name_len + 1);

Mp3.volume(vol);

EEPROM.write(vol);

Part D. Pause to Learn About Interrupts

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

 

3.3V

   |

resistor

   |

    ------< Arduino

   |

    \    (button)

   |

ground

 

Pressing the button completes the circuit and puts power to the Arduino pin. This triggers the interrupt. There also needs to be some debouncing in the code to prevent the hardware button from bouncing against the metal inside multiple times and triggering the interrupt.

What are the pros and cons of using this method?

Here are the pros and cons of using button interrupts.

Pros:

- Not checking every tick if button state is HIGH.

- Removes all delays in the code.

Cons:

- More code necessary and harder to program.

- Occasionally less accurate with bouncing.

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

// Initialize libraries here, SD card, LCD, and mp3. 

void mp3_pause() {

  if(current_state == MP3_PLAY){

    current_state = PAUSED;

    lcd.println("Paused");

  }

  else {

    current_state=MP3_PLAY;

  }

}

 

void setup() {

  attachInterrupt(2,mp3_pause,FALLING);

  lcd.begin(55);

  lcd.clearDisplay();

  lcd.println("Barebones Mp3!");

  lcd.display();

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

  Mp3.volume(190);

  sd_card_setup();

  sd_dir_setup();

  sd_file_open();

}

 

void loop() {

  switch(current_state) {

    case DIR_PLAY:

      dir_play();

      break; 

    case MP3_PLAY:

      mp3_play();

      break; 

    case PAUSED:

      break;

  }

}

 

Comments (1)

xinyi xie said

at 10:19 pm on Aug 16, 2014

Great job!

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