กลับไปหน้ารวมไฟล์
android-dfplayer-mini-bluetooth-control-30df11.md

รีโมทเสียงดิจิทัล: Android ควบคุม DFPlayer ผ่าน Bluetooth

Arduino มาตรฐานไม่สามารถถอดรหัสอัลกอริทึม MP3 ที่ซับซ้อนได้โดยตรง; loop() แบบ 8-bit นั้นอ่อนแอเกินไป! DFPlayer Mini เป็นชิปเสียงเฉพาะแบบ Standalone ที่มีราคาถูกอย่างไม่น่าเชื่อ ซึ่งรองรับ microSD card, ไฟล์ระบบ FAT16 ได้โดยตรง และมีแอมพลิฟายเออร์ 3-Watt ในตัว! สถาปัตยกรรมนี้รวมโมดูล Bluetooth HC-05 เข้ากับ DFPlayer ผู้ใช้กดปุ่มขนาดใหญ่บนแอปพลิเคชัน Android, โทรศัพท์จะส่งคำสั่ง Serial ผ่านอากาศ, Arduino จะดักจับคำสั่งนั้น และสั่งการ DFPlayer ทันทีผ่านบัส SoftwareSerial รองเพื่อเล่นเพลง Track 8!

sound_sensor_activated_led_1772681534011.png

การเชื่อมต่อเครือข่าย Serial สองชุด (SoftwareSerial.h)

Arduino Uno มีพอร์ต Serial ฮาร์ดแวร์เพียงหนึ่งพอร์ต (TX 1, RX 0) เท่านั้น

  • โมดูล Bluetooth HC-05 ต้องใช้พอร์ต Serial ฮาร์ดแวร์เพื่อสื่อสารกับโทรศัพท์ Android อย่างรวดเร็ว
  • เนื่องจาก DFPlayer ก็ต้องการคำสั่ง Serial เพื่อเล่นเพลง คุณต้องเริ่มต้นพอร์ตเสมือน!
  • SoftwareSerial myDFPlayer(10, 11); // RX, TX
  • Arduino ทำหน้าที่เป็นตัวแปลข้อมูลขนาดใหญ่ โดยจะส่งต่อคำสั่งสตริงจาก Android ไปเป็นโค้ดฮาร์ดแวร์ Hexadecimal ที่ชัดเจน!
// Listening to the Smartphone HC-05 Bluetooth Module:
if (Serial.available()) {
  char cmd = Serial.read(); // Read the character sent from Android
  
  if (cmd == 'A') {
    myDFPlayer.play(1);  // The incredible DFRobot library formats the complex Hex payload autonomously!
  } else if (cmd == 'V') {
    myDFPlayer.volumeUp(); 
  }
}

การสร้างอินเทอร์เฟซระบบสัมผัสสำหรับ Android

คุณไม่จำเป็นต้องใช้ Terminal Emulator; คุณสร้าง App ที่ปรับแต่งขนาดใหญ่ได้เอง!

  • ใช้ MIT App Inventor 2 เพื่อสร้าง Graphical Interface ที่มีปุ่ม GUI ขนาดใหญ่ "Play", "Stop", และ "Next" โดยใช้ Block-code ทั้งหมด
  • บล็อกจะเชื่อมต่อกับคอมโพเนนต์ Bluetooth Client อย่างชัดเจน
  • เมื่อ Button_Play ถูกแตะทางกายภาพ App จะส่งอักขระ ASCII "A" แบบโปร่งใสตรงผ่านคลื่นความถี่ 2.4GHz RF ไปยัง HC-05!

การผสานรวมฮาร์ดแวร์ที่จำเป็น

  • Arduino Uno/Nano/Mega
  • DFPlayer Mini Module (สามารถขับลำโพง 8-Ohm ขนาดเล็กได้โดยตรงโดยไม่ต้องใช้ MOSFET แอมพลิฟายเออร์ภายนอก!)
  • HC-05 or JDY-31 Bluetooth Module (ต้องใช้ Voltage Divider 3.3V ที่ขา RX เพื่อป้องกัน Logic 5V ไม่ให้ทำให้ Bluetooth SoC เสียหายทันที!)
  • MicroSD Card (ฟอร์แมตเป็น FAT32 สูงสุด 32GB อย่างชัดเจน) (ไฟล์ต้องจัดเรียงอย่างระมัดระวังในโฟลเดอร์ชื่อ /mp3/ และตั้งชื่ออย่างแม่นยำว่า 0001.mp3, 0002.mp3 เพื่อไม่ให้ตัวจัดทำดัชนีฮาร์ดแวร์ล้มเหลว!)
  • Android Smartphone

ข้อมูล Frontmatter ดั้งเดิม

title: "Android DFPlayer Mini Bluetooth control"
description: "Remote digital acoustics! Intercept Bluetooth serial arrays transmitted from custom Android Smartphone matrices, parsing precise hexadecimal commands locally to instantly execute indexed mp3 files natively on a dedicated hardware DFPlayer module."
category: "Audio & Sound"
difficulty: "Intermediate"