daily pastebin goal
33%
SHARE
TWEET

BlizzyB Sine Ed. Firmware v0.2

weaknetlabs Oct 10th, 2014 202 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.    - WeakNetLabs@Gmail.com
  7. */
  8. #include <SD.h> // preprocessor directives (header files)
  9. #define SDPIN 10    // SD Card Pin for SeeedStudio SD Card Shield
  10. #include <TMRpcm.h> // to play WAV files
  11. #include <Keypad.h> // for the keypad
  12. int b2600 = 14; // 2600Hz Supervisory Signalling button
  13. File myFile; // create objects here from library classes
  14. TMRpcm tmrpcm; // create sound playing object
  15. char keys[4][4] = { // matrix layout used by the Keypad library
  16.   {'1','2','3','a'},
  17.   {'4','5','6','b'},
  18.   {'7','8','9','c'},
  19.   {'*','0','#','d'}
  20. };
  21. byte rowPins[4] = {5,4,3,2}; //connect to the row pinouts of the keypad
  22. byte colPins[4] = {14,8,7,6}; //connect to the column pinouts of the keypad
  23. Keypad keypad = Keypad(makeKeymap(keys),rowPins,colPins,4,4);
  24.  
  25. void setup(){
  26.   pinMode(b2600, INPUT); // A1 2600 button
  27.   tmrpcm.speakerPin = 9; //11 on Mega, 9 on Uno, Nano, etc
  28.   tmrpcm.setVolume(3); // set volume here (test for distortion)
  29.   tmrpcm.play("sounds/blusinbu.wav"); // start up sound
  30.   delay(1000); // pause
  31.   return;
  32. }
  33.  
  34. void loop(){ // our main loop
  35.   procButton(); // process input
  36.   if(digitalRead(b2600)==HIGH){ // play 2600Hz if button pressed
  37.     super(); // supervisory signalling
  38.   }
  39.   return;
  40. }
  41.  
  42. void super(){ // this is it's own, for future expansion
  43.   tmrpcm.play("sounds/blusin26.wav");
  44.   return;
  45. }
  46.  
  47. void procButton(void){
  48.   char button = keypad.getKey();
  49.   if (button){ // if a button was pressed
  50.     int intB = button - 48; // get Blue Box element index
  51.     if(intB>-1&&intB<10){ // 0-9
  52.       char convert[2]; // these next few lines convert intB to char for sending
  53.       String str;  //        filename string into the play method of the TMRpcm object
  54.       str=String(intB);
  55.       str.toCharArray(convert,2);
  56.       char string[20] = "sounds/blusin0X.wav"; // X gets replaced
  57.       string[14] = *convert;
  58.       tmrpcm.play(string);
  59.       delay(100);
  60.     }else if(intB==-6){ // KP
  61.       tmrpcm.play("sounds/blusinkp.wav");
  62.     }else if(intB==-13){ // ST
  63.       tmrpcm.play("sounds/blusinst.wav");
  64.     }else if(intB==49){ // 2600 (Assigned to 'A' for now
  65.       super();
  66.     }
  67.   }else{
  68.     return; // no button pressed
  69.   }
  70. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top