Drum Portable Arduino
Author
Cak Lihat
Date
17 Jul 2019
Views
136

File suara yang didukung hanya 8bit wav bitrate 11100, berikut source codenya dan skematiknya :


#include <SimpleSDAudio.h>

void setup() {
  // put your setup code here, to run once:
  SdPlay.setSDCSPin(4);

  if(!SdPlay.init(SSDA_MODE_FULLRATE|SSDA_MODE_STEREO|SSDA_MODE_AUTOWORKER))
  {while(1);}
  // put your setup code here, to run once:
  pinMode(7, INPUT);
  pinMode(8, INPUT);
  pinMode(6, OUTPUT);

}

void loop() {
  // put your main code here, to run repeatedly:
  if(digitalRead(8)==HIGH){
    digitalWrite(6, HIGH);
    if(!SdPlay.setFile("snare.wav"))
    {while(0);}

    SdPlay.play();
  }
  else if(digitalRead(2)==HIGH){
    digitalWrite(6, HIGH);
    if(!SdPlay.setFile("kick.wav"))
    {while(0);}

    SdPlay.play();
  }
  else if(digitalRead(3)==HIGH){
    digitalWrite(6, HIGH);
    if(!SdPlay.setFile("crash.wav"))
    {while(0);}

    SdPlay.play();
  }
  else{
    digitalWrite(6, LOW);
  }

}



0 Comments

We'll never share your email with anyone else.