Advertisement
Guest User

Untitled

a guest
Mar 13th, 2012
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. #include <SPI.h>
  2. #include <SdFat.h>
  3. #include <SdFatUtil.h>
  4. #include <SFEMP3Shield.h>
  5. #include <Keypad.h>
  6.  
  7. const byte ROWS = 4; //four rows
  8. const byte COLS = 4; //four columns
  9. char keys[ROWS][COLS] = {
  10.   {1,2,3,4},
  11.   {5,6,7,8},
  12.   {9,10,11,12},
  13.   {13,14,15,16}
  14. };
  15. byte rowPins[ROWS] = {A2,A3,A4,A5}; //connect to the row pinouts of the keypad
  16. byte colPins[COLS] = {A1,A0,4,5}; //connect to the column pinouts of the keypad
  17.  
  18. Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
  19.  
  20. SFEMP3Shield MP3player;
  21.  
  22.  
  23.  
  24. void setup() {
  25.  
  26.   Serial.begin(9600);
  27.  
  28.   //start the shield
  29.   MP3player.begin();
  30.   keypad.setDebounceTime(200);
  31.  
  32. }
  33.  
  34. //do something else now
  35. void loop() {
  36.  
  37.   char key = keypad.waitForKey();
  38.   byte play = MP3player.isPlaying();
  39.   while (play == 1){play = MP3player.isPlaying();Serial.println("waiting");}
  40.   MP3player.stopTrack();
  41.   Serial.print("stopping");
  42.   Serial.println(key);
  43.   if (key != NO_KEY){
  44.     Serial.print("playing");
  45.     char result = MP3player.playTrack(1);
  46.     Serial.print("playing");
  47.     Serial.println(result);
  48.   }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement