DFPlayer: Skirtumas tarp puslapio versijų
Jump to navigation
Jump to search
(Naujas puslapis: Mini mp3 grotuvas skirtas veikti su mikrovaldikliais. 800px Galimi pavadinimai: * DFPlayer * MP3-TF-16P * MP3-TF-16P V3.0 = ESP32 Pajungi...) |
|||
(nerodoma 2 tarpinės versijos, sukurtos to paties naudotojo) | |||
11 eilutė: | 11 eilutė: | ||
= ESP32 Pajungimas = | = ESP32 Pajungimas = | ||
+ | == 3V3 Versija == | ||
* ESP32 PIN 16 (hardware serial2 rx) -> DFPlayer TX | * ESP32 PIN 16 (hardware serial2 rx) -> DFPlayer TX | ||
− | * ESP32 PIN 17 (hardware serial2 tx) -> DFPlayer RX | + | * ESP32 PIN 17 (hardware serial2 tx) -> DFPlayer RX |
* ESP32 3V3 -> DFPlayer VCC | * ESP32 3V3 -> DFPlayer VCC | ||
* ESP32 GND -> DFPlayer GND | * ESP32 GND -> DFPlayer GND | ||
* Taip pat prie RX ir GND dedamas 100k rezistorius. | * Taip pat prie RX ir GND dedamas 100k rezistorius. | ||
+ | * Speaker (mono) + DFPlayer SPK1 | ||
+ | * Speaker (mono) - DFPlayer SPK2 | ||
+ | |||
+ | == 5V Versija == | ||
+ | * ESP32 PIN 16 (hardware serial2 rx) -> DFPlayer TX | ||
+ | * ESP32 PIN 17 (hardware serial2 tx) 1k rezistorius -> DFPlayer RX | ||
+ | * ESP32 3V3 -> DFPlayer VCC | ||
+ | * ESP32 GND -> DFPlayer GND | ||
+ | * Tarp VCC ir GND 470-1000uF kondensatorius | ||
* Speaker (mono) + DFPlayer SPK1 | * Speaker (mono) + DFPlayer SPK1 | ||
* Speaker (mono) - DFPlayer SPK2 | * Speaker (mono) - DFPlayer SPK2 | ||
98 eilutė: | 108 eilutė: | ||
Serial.print("volume "); | Serial.print("volume "); | ||
Serial.println(volume); | Serial.println(volume); | ||
− | dfmp3.setVolume( | + | dfmp3.setVolume(5); |
− | + | delay(1000); | |
uint16_t count = dfmp3.getTotalTrackCount(DfMp3_PlaySource_Sd); | uint16_t count = dfmp3.getTotalTrackCount(DfMp3_PlaySource_Sd); | ||
Serial.print("files "); | Serial.print("files "); |
Dabartinė 01:37, 4 gruodžio 2022 versija
Mini mp3 grotuvas skirtas veikti su mikrovaldikliais.
Galimi pavadinimai:
- DFPlayer
- MP3-TF-16P
- MP3-TF-16P V3.0
ESP32 Pajungimas[keisti]
3V3 Versija[keisti]
- ESP32 PIN 16 (hardware serial2 rx) -> DFPlayer TX
- ESP32 PIN 17 (hardware serial2 tx) -> DFPlayer RX
- ESP32 3V3 -> DFPlayer VCC
- ESP32 GND -> DFPlayer GND
- Taip pat prie RX ir GND dedamas 100k rezistorius.
- Speaker (mono) + DFPlayer SPK1
- Speaker (mono) - DFPlayer SPK2
5V Versija[keisti]
- ESP32 PIN 16 (hardware serial2 rx) -> DFPlayer TX
- ESP32 PIN 17 (hardware serial2 tx) 1k rezistorius -> DFPlayer RX
- ESP32 3V3 -> DFPlayer VCC
- ESP32 GND -> DFPlayer GND
- Tarp VCC ir GND 470-1000uF kondensatorius
- Speaker (mono) + DFPlayer SPK1
- Speaker (mono) - DFPlayer SPK2
Žinotina, kad žmonės naudoja ir stereo su šiuo grotuvu (asmeniškai neišbandyta). Naudojama arduino biblioteka: https://github.com/Makuna/DFMiniMp3
Kodo pavyzdys[keisti]
#include <DFMiniMp3.h>
// forward declare the notify class, just the name
//
class Mp3Notify;
// define a handy type using serial and our notify class
//
typedef DFMiniMp3<HardwareSerial, Mp3Notify> DfMp3;
// instance a DfMp3 object,
//
DfMp3 dfmp3(Serial2);
class Mp3Notify
{
public:
static void PrintlnSourceAction(DfMp3_PlaySources source, const char* action)
{
if (source & DfMp3_PlaySources_Sd)
{
Serial.print("SD Card, ");
}
if (source & DfMp3_PlaySources_Usb)
{
Serial.print("USB Disk, ");
}
if (source & DfMp3_PlaySources_Flash)
{
Serial.print("Flash, ");
}
Serial.println(action);
}
static void OnError([[maybe_unused]] DfMp3& mp3, uint16_t errorCode)
{
// see DfMp3_Error for code meaning
Serial.println();
Serial.print("Com Error ");
Serial.println(errorCode);
}
static void OnPlayFinished([[maybe_unused]] DfMp3& mp3, [[maybe_unused]] DfMp3_PlaySources source, uint16_t track)
{
Serial.print("Play finished for #");
Serial.println(track);
}
static void OnPlaySourceOnline([[maybe_unused]] DfMp3& mp3, DfMp3_PlaySources source)
{
PrintlnSourceAction(source, "online");
}
static void OnPlaySourceInserted([[maybe_unused]] DfMp3& mp3, DfMp3_PlaySources source)
{
PrintlnSourceAction(source, "inserted");
}
static void OnPlaySourceRemoved([[maybe_unused]] DfMp3& mp3, DfMp3_PlaySources source)
{
PrintlnSourceAction(source, "removed");
}
};
void setup()
{
Serial.begin(115200);
Serial.println("initializing...");
dfmp3.begin();
dfmp3.reset();
// show some properties and set the volume
uint16_t volume = dfmp3.getVolume();
Serial.print("volume ");
Serial.println(volume);
dfmp3.setVolume(5);
delay(1000);
uint16_t count = dfmp3.getTotalTrackCount(DfMp3_PlaySource_Sd);
Serial.print("files ");
Serial.println(count);
uint16_t mode = dfmp3.getPlaybackMode();
Serial.print("playback mode ");
Serial.println(mode);
Serial.println("starting...");
dfmp3.playRandomTrackFromAll(); // random of all folders on sd
}
void loop()
{
// calling dfmp3.loop() periodically allows for notifications
// to be handled without interrupts
dfmp3.loop();
}
Pavyzdys groja atsitiktinius įrašus iš microSD kortelės, suformatuotos kaip FAT32 palaikoma iki 32GB kortelės. Išbandyta su Good Ram MicroSDHC I 32GB. Taip pat reikalinga tam tikra hierarchija failų sistemoja, norint, kad tinkamai veiktų, plačiau galima paskaityti bibliotekos autoriaus repozitorijoje.