Advertisement
weaknetlabs

BlizzyB Sine Ed. Firmware v0.2

Oct 10th, 2014
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.38 KB | None | 0 0
  1. /*
  2.   BlizzyB Sine Ed. - Douglas Berdeaux 2014 (C) GNU
  3.   Firmware version 0.2 (Still in BETA)
  4.   This project requires a lot of knowledge about SD card reading and the TMRpcm library.
  5.   Please see WeakNetLabs.com for more details.
  6. */
  7. #include <SD.h> // preprocessor directives (header files)
  8. #define SDPIN 10    // SD Card Pin for SeeedStudio SD Card Shield
  9. #include <TMRpcm.h> // to play WAV files
  10. #include <Keypad.h> // for the keypad
  11. int b2600 = 14; // 2600Hz Supervisory Signalling button
  12. File myFile; // create objects here from library classes
  13. TMRpcm tmrpcm; // create sound playing object
  14. char keys[4][4] = { // matrix layout used by the Keypad library
  15.   {'1','2','3','a'},
  16.   {'4','5','6','b'},
  17.   {'7','8','9','c'},
  18.   {'*','0','#','d'}
  19. };
  20. byte rowPins[4] = {5,4,3,2}; //connect to the row pinouts of the keypad
  21. byte colPins[4] = {14,8,7,6}; //connect to the column pinouts of the keypad
  22. Keypad keypad = Keypad(makeKeymap(keys),rowPins,colPins,4,4);
  23.  
  24. void setup(){
  25.   pinMode(b2600, INPUT); // A1 2600 button
  26.   tmrpcm.speakerPin = 9; //11 on Mega, 9 on Uno, Nano, etc
  27.   tmrpcm.setVolume(3); // set volume here (test for distortion)
  28.   tmrpcm.play("sounds/blusinbu.wav"); // start up sound
  29.   delay(1000); // pause
  30.   return;
  31. }
  32.  
  33. void loop(){ // our main loop
  34.   procButton(); // process input
  35.   if(digitalRead(b2600)==HIGH){ // play 2600Hz if button pressed
  36.     super(); // supervisory signalling
  37.   }
  38.   return;
  39. }
  40.  
  41. void super(){ // this is it's own, for future expansion
  42.   tmrpcm.play("sounds/blusin26.wav");
  43.   return;
  44. }
  45.  
  46. void procButton(void){
  47.   char button = keypad.getKey();
  48.   if (button){ // if a button was pressed
  49.     int intB = button - 48; // get Blue Box element index
  50.     if(intB>-1&&intB<10){ // 0-9
  51.       char convert[2]; // these next few lines convert intB to char for sending
  52.       String str;  //        filename string into the play method of the TMRpcm object
  53.       str=String(intB);
  54.       str.toCharArray(convert,2);
  55.       char string[20] = "sounds/blusin0X.wav"; // X gets replaced
  56.       string[14] = *convert;
  57.       tmrpcm.play(string);
  58.       delay(100);
  59.     }else if(intB==-6){ // KP
  60.       tmrpcm.play("sounds/blusinkp.wav");
  61.     }else if(intB==-13){ // ST
  62.       tmrpcm.play("sounds/blusinst.wav");
  63.     }else if(intB==49){ // 2600 (Assigned to 'A' for now
  64.       super();
  65.     }
  66.   }else{
  67.     return; // no button pressed
  68.   }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement