Created
March 5, 2015 19:37
-
-
Save sezgingul/f7838c8532a1cfea5045 to your computer and use it in GitHub Desktop.
Arduino ile Sd karttan melodi çalma
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Arduino ile melodi çalma uygulaması by Sezgin GÜL | |
//sd kart moduldeki pin girişleri ** MOSI - pin 11 ** MISO - pin 12** CLK - pin 13** CS - pin 4 | |
#include <SD.h> // sd kart kütüphanesi | |
#define Sd_Chip_pin 4 | |
#include <TMRpcm.h> // melodi çalma kütüphanesi | |
char val; | |
TMRpcm tmrpcm; // melodi fonksiyonu oluşturma | |
void setup(){ | |
Serial.begin(9600); | |
tmrpcm.speakerPin = 9; // hoparlör + bacağı digital 9. pine tak | |
if (!SD.begin(Sd_Chip_pin)) { // sd module bağlanma | |
return; | |
} | |
} | |
void loop(){ | |
if (Serial.available()) { | |
delay(100); | |
while(Serial.available() > 0){ | |
val = Serial.read(); | |
if (val == '1') { // 1 verisi gönderdiğinde 1.wav dosyasını çal | |
tmrpcm.play("1.wav"); | |
} else if(val == '2'){ // 2 verisi gönderdiğinde 1.wav dosyasını çal | |
tmrpcm.play("2.wav"); | |
} else if(val == '3'){ // 3 verisi gönderdiğinde 1.wav dosyasını çal | |
tmrpcm.play("3.wav"); | |
} else if(val == '4'){ // 4 verisi gönderdiğinde 1.wav dosyasını çal | |
tmrpcm.play("4.wav"); | |
} | |
else if(val == '5'){ // 5 verisi gönderdiğinde 1.wav dosyasını çal | |
tmrpcm.play("5.wav"); | |
} | |
else if(val == '6'){ // 6 verisi gönderdiğinde 1.wav dosyasını çal | |
tmrpcm.play("6.wav"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment