MP3 audio file playback from SD Card with Arduino

You may also like...

7 Responses

  1. Rokib Hasan says:

    what should i do? when i try to add library arduino IDE shows this message.
    Specified folder/zip file does not contain a valid library
    Invalid library found in C:\Users\Rokib hasan\Documents\Arduino\libraries\arduino: C:\Users\Rokib hasan\Documents\Arduino\libraries\arduino
    Invalid library found in C:\Users\Rokib hasan\Documents\Arduino\libraries\arduino: C:\Users\Rokib hasan\Documents\Arduino\libraries\arduino

  2. Medjai says:

    Greetings!
    Good decision, but please help.
    How to make that sound starts when you press the button? And stops after its release as a car horn.
    And whether it is possible to make some buttons with different sounds?
    Thanks for the help!

  3. Daniel Tsonkov says:

    This is not MP3 player…..This is WAV player. 🙁

  4. Hakan Baytemür says:

    /*
    Author:Hakan Baytemür
    No:B170918045
    Mekatronik mühendisliği 1. dönem programlama proje ödevi.
    Proje adı: Keypad güvenlik sistemi. (Sesli)
    */
    #include
    #include
    #include //I2C protokolünü LCD ile kullanmak için gereken kütüphanesini dahil ettik.
    #include //Keypad kütüphanesini dahil ettik.
    #include //Servo kütüphanesini dahil ettik.
    #define redLED 5 //Led pinleri atandı.
    #define greenLED 4
    #define buzzer 3 //Buzzer pini atandı.
    LiquidCrystal_I2C lcd(0x27, 16, 2);
    Servo sg90;
    const byte rows = 4; //Sütun ve kolonların sayısı atandı.
    const byte cols = 4;
    const int segment_display1 = 30; //7 segment göstergenin pinlerinin yerleri atandı.
    const int segment_display2 = 31;
    const int segment_display3 = 32;
    const int segment_display4 = 33;
    const int segment_display5 = 34;
    const int segment_display6 = 35;
    const int segment_display7 = 36;
    const int segment_display8 = 37;
    int i;

    char sifre[4] = {‘*’, ‘#’, ‘C’, ‘9’}; //default password we can change it fromere and also change it int he void loop!
    char sifre1[4]; //password that we will click on the keypad
    char whichKey; //char key

    char keyMap [rows] [cols] = { //Keypad karakterleri belirlendi.

    {‘1’, ‘2’, ‘3’, ‘A’},
    {‘4’, ‘5’, ‘6’, ‘B’},
    {‘7’, ‘8’, ‘9’, ‘C’},
    {‘*’, ‘0’, ‘#’, ‘D’}
    };

    byte rowPins [rows] = {13, 12, 11, 10}; //Keypadin sütun pinleri atandı.
    byte colPins [cols] = {9, 8, 7, 6}; //Keypadin kolon pinleri atandı.

    Keypad myKeypad = Keypad( makeKeymap(keyMap), rowPins, colPins, rows, cols);//Keypadin haritası oluşturuldu.

    void setup()
    {
    SdPlay.setSDCSPin(53); // sd kart cs pini
    if (!SdPlay.init(SSDA_MODE_HALFRATE | SSDA_MODE_MONO | SSDA_MODE_AUTOWORKER))
    {
    while (1);
    }
    if (!SdPlay.setFile(“1.wav”)) // müzik dosya adı
    {
    while (1); //dosya bulunamassa durdur
    }
    sg90.attach(46);//Servo motorun pini atandı.
    lcd.begin();
    pinMode(redLED, OUTPUT); //LED’lerin pinleri çıkış olarak ayarlandı.
    pinMode(greenLED, OUTPUT);
    pinMode(buzzer , OUTPUT); //Buzzerin pini çıkış olarak ayarlandı.
    pinMode(segment_display1 , OUTPUT); //7 segment displayın pinleri çıkış olarak ayarlandı.
    pinMode(segment_display2 , OUTPUT);
    pinMode(segment_display3 , OUTPUT);
    pinMode(segment_display4 , OUTPUT);
    pinMode(segment_display5 , OUTPUT);
    pinMode(segment_display6 , OUTPUT);
    pinMode(segment_display7 , OUTPUT);
    pinMode(segment_display8 , OUTPUT);
    digitalWrite(buzzer, HIGH);
    }

    void loop() {
    sg90.write(90);
    char whichKey = myKeypad.getKey(); //getKey ile hangi tuşa basıldığını atadık.
    digitalWrite(redLED, HIGH);
    digitalWrite(greenLED, LOW);
    lcd.setCursor(0, 0);
    lcd.print(” Enter Password “);
    if (whichKey) //if key (tus then it will process as follow
    {
    sifre1[i++] = whichKey; //everytime we click keypad ,sifre1=password1 will be [0] to [1] to[2]…. till 4. element of array
    lcd.setCursor(i, 1);
    lcd.print(“*”); // i have used * this charecter so that passwords that we print on the screen can not be seen from anyone else
    digitalWrite(buzzer, LOW);
    delay(50);
    digitalWrite(buzzer, HIGH);
    }

    if (i == 4)
    { delay(200);
    if ((strncmp(sifre1, sifre, 4) == 0)) //comparing these passwords if first 4 element correct then process will be as follows
    {
    delay(500);
    lcd.clear();
    lcd.setCursor(0, 0);
    sg90.write(270);
    lcd.print(” ACCESS GRANTED”); //password correct
    digitalWrite(greenLED, HIGH);
    digitalWrite(redLED, LOW);
    if (redLED == HIGH)
    {
    SdPlay.play(); // seçilen dosyayı çal
    while (!SdPlay.isStopped()) { // müzik bittiğinde tekrar çal
    ;
    }
    }
    digitalWrite(segment_display1 , LOW);//9
    digitalWrite(segment_display2 , HIGH);
    digitalWrite(segment_display3 , HIGH);
    digitalWrite(segment_display4 , LOW);
    digitalWrite(segment_display5 , HIGH);
    digitalWrite(segment_display6 , HIGH);
    digitalWrite(segment_display7 , HIGH);
    digitalWrite(segment_display8 , HIGH);
    delay(1000);
    digitalWrite(segment_display1 , LOW);//8
    digitalWrite(segment_display2 , HIGH);
    digitalWrite(segment_display3 , HIGH);
    digitalWrite(segment_display4 , HIGH);
    digitalWrite(segment_display5 , HIGH);
    digitalWrite(segment_display6 , HIGH);
    digitalWrite(segment_display7 , HIGH);
    digitalWrite(segment_display8 , HIGH);
    delay(1000);
    digitalWrite(segment_display1 , LOW);//7
    digitalWrite(segment_display2 , HIGH);
    digitalWrite(segment_display3 , LOW);
    digitalWrite(segment_display4 , LOW);
    digitalWrite(segment_display5 , HIGH);
    digitalWrite(segment_display6 , HIGH);
    digitalWrite(segment_display7 , HIGH);
    digitalWrite(segment_display8 , LOW);
    delay(1000);
    digitalWrite(segment_display1 , LOW);//6
    digitalWrite(segment_display2 , HIGH);
    digitalWrite(segment_display3 , HIGH);
    digitalWrite(segment_display4 , HIGH);
    digitalWrite(segment_display5 , LOW);
    digitalWrite(segment_display6 , HIGH);
    digitalWrite(segment_display7 , HIGH);
    digitalWrite(segment_display8 , HIGH);
    delay(1000);
    digitalWrite(segment_display1 , LOW);//5
    digitalWrite(segment_display2 , HIGH);
    digitalWrite(segment_display3 , HIGH);
    digitalWrite(segment_display4 , LOW);
    digitalWrite(segment_display5 , LOW);
    digitalWrite(segment_display6 , HIGH);
    digitalWrite(segment_display7 , HIGH);
    digitalWrite(segment_display8 , HIGH);
    delay(1000);
    digitalWrite(segment_display1 , LOW);//4
    digitalWrite(segment_display2 , HIGH);
    digitalWrite(segment_display3 , LOW);
    digitalWrite(segment_display4 , LOW);
    digitalWrite(segment_display5 , HIGH);
    digitalWrite(segment_display6 , LOW);
    digitalWrite(segment_display7 , HIGH);
    digitalWrite(segment_display8 , HIGH);
    delay(1000);
    digitalWrite(segment_display1 , LOW);//3
    digitalWrite(segment_display2 , HIGH);
    digitalWrite(segment_display3 , HIGH);
    digitalWrite(segment_display4 , LOW);
    digitalWrite(segment_display5 , HIGH);
    digitalWrite(segment_display6 , HIGH);
    digitalWrite(segment_display7 , LOW);
    digitalWrite(segment_display8 , HIGH);
    delay(1000);
    digitalWrite(segment_display1 , LOW);//2
    digitalWrite(segment_display2 , LOW);
    digitalWrite(segment_display3 , HIGH);
    digitalWrite(segment_display4 , HIGH);
    digitalWrite(segment_display5 , HIGH);
    digitalWrite(segment_display6 , HIGH);
    digitalWrite(segment_display7 , LOW);
    digitalWrite(segment_display8 , HIGH);
    delay(1000);
    digitalWrite(segment_display1 , LOW);//1
    digitalWrite(segment_display2 , HIGH);
    digitalWrite(segment_display3 , LOW);
    digitalWrite(segment_display4 , LOW);
    digitalWrite(segment_display5 , HIGH);
    digitalWrite(segment_display6 , LOW);
    digitalWrite(segment_display7 , LOW);
    digitalWrite(segment_display8 , LOW);
    delay(1000);
    digitalWrite(segment_display1 , LOW);//0
    digitalWrite(segment_display2 , HIGH);
    digitalWrite(segment_display3 , HIGH);
    digitalWrite(segment_display4 , HIGH);
    digitalWrite(segment_display5 , HIGH);
    digitalWrite(segment_display6 , HIGH);
    digitalWrite(segment_display7 , HIGH);
    digitalWrite(segment_display8 , LOW);
    delay(1000);
    i = 0;
    }
    else
    {
    delay(500);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print(” ACCESS DENIED!!!”); //wrong password
    digitalWrite(greenLED, HIGH);
    digitalWrite(redLED, HIGH);
    digitalWrite(segment_display1 , HIGH);
    digitalWrite(segment_display2 , HIGH);
    digitalWrite(segment_display3 , HIGH);
    digitalWrite(segment_display4 , HIGH);
    digitalWrite(segment_display5 , HIGH);
    digitalWrite(segment_display6 , HIGH);
    digitalWrite(segment_display7 , HIGH);
    digitalWrite(segment_display8 , HIGH);
    delay(500);
    digitalWrite(greenLED, LOW);
    digitalWrite(redLED, LOW);
    digitalWrite(segment_display1 , LOW);
    digitalWrite(segment_display2 , LOW);
    digitalWrite(segment_display3 , LOW);
    digitalWrite(segment_display4 , LOW);
    digitalWrite(segment_display5 , LOW);
    digitalWrite(segment_display6 , LOW);
    digitalWrite(segment_display7 , LOW);
    digitalWrite(segment_display8 , LOW);
    delay(500);
    digitalWrite(greenLED, HIGH);
    digitalWrite(redLED, HIGH);
    digitalWrite(segment_display1 , HIGH);
    digitalWrite(segment_display2 , HIGH);
    digitalWrite(segment_display3 , HIGH);
    digitalWrite(segment_display4 , HIGH);
    digitalWrite(segment_display5 , HIGH);
    digitalWrite(segment_display6 , HIGH);
    digitalWrite(segment_display7 , HIGH);
    digitalWrite(segment_display8 , HIGH);
    delay(500);
    digitalWrite(greenLED, LOW);
    digitalWrite(redLED, LOW);
    digitalWrite(segment_display1 , LOW);
    digitalWrite(segment_display2 , LOW);
    digitalWrite(segment_display3 , LOW);
    digitalWrite(segment_display4 , LOW);
    digitalWrite(segment_display5 , LOW);
    digitalWrite(segment_display6 , LOW);
    digitalWrite(segment_display7 , LOW);
    digitalWrite(segment_display8 , LOW);
    delay(500);
    digitalWrite(greenLED, HIGH);
    digitalWrite(redLED, HIGH);
    digitalWrite(segment_display1 , HIGH);
    digitalWrite(segment_display2 , HIGH);
    digitalWrite(segment_display3 , HIGH);
    digitalWrite(segment_display4 , HIGH);
    digitalWrite(segment_display5 , HIGH);
    digitalWrite(segment_display6 , HIGH);
    digitalWrite(segment_display7 , HIGH);
    digitalWrite(segment_display8 , HIGH);
    delay(500);
    digitalWrite(greenLED, LOW);
    digitalWrite(redLED, LOW);
    digitalWrite(segment_display1 , LOW);
    digitalWrite(segment_display2 , LOW);
    digitalWrite(segment_display3 , LOW);
    digitalWrite(segment_display4 , LOW);
    digitalWrite(segment_display5 , LOW);
    digitalWrite(segment_display6 , LOW);
    digitalWrite(segment_display7 , LOW);
    digitalWrite(segment_display8 , LOW);
    delay(500);
    digitalWrite(greenLED, HIGH);
    digitalWrite(redLED, HIGH);
    digitalWrite(segment_display1 , HIGH);
    digitalWrite(segment_display2 , HIGH);
    digitalWrite(segment_display3 , HIGH);
    digitalWrite(segment_display4 , HIGH);
    digitalWrite(segment_display5 , HIGH);
    digitalWrite(segment_display6 , HIGH);
    digitalWrite(segment_display7 , HIGH);
    digitalWrite(segment_display8 , HIGH);
    delay(500);
    digitalWrite(greenLED, LOW);
    digitalWrite(redLED, LOW);
    digitalWrite(segment_display1 , LOW);
    digitalWrite(segment_display2 , LOW);
    digitalWrite(segment_display3 , LOW);
    digitalWrite(segment_display4 , LOW);
    digitalWrite(segment_display5 , LOW);
    digitalWrite(segment_display6 , LOW);
    digitalWrite(segment_display7 , LOW);
    digitalWrite(segment_display8 , LOW);
    delay(500);
    i = 0;
    }
    }
    }
    I use SimpleSAudio.h library this code but ıt didn’t work. This is a keypad security systems arduino code. When I key true password LCD display “ACCESS GRANTED” but speaker didn’t work. Please help me.

Leave a Reply to Sezgin Gül Cancel reply

Your email address will not be published. Required fields are marked *