Cov txheej txheem:

AdaBox004 Music Player: 4 Kauj Ruam
AdaBox004 Music Player: 4 Kauj Ruam

Video: AdaBox004 Music Player: 4 Kauj Ruam

Video: AdaBox004 Music Player: 4 Kauj Ruam
Video: Hmong Zinc - Tseem Nco 2024, Hlis ntuj nqeg
Anonim
AdaBox004 Music Player
AdaBox004 Music Player

Kuv siv cov ntu hauv AdaBox004 los ua lub suab paj nruag yooj yim. Nws ntsaws rau hauv USB chaw nres nkoj thiab pib ua nkauj tsis zoo los ntawm daim npav micro SD. Nws yog rau kuv qhov kev cob qhia rau qhov tsis muaj fuss qhov ntawm upbeat nkauj.

Kauj Ruam 1: Qhov Chaw

AdaBox004 (https://www.adafruit.com/product/3370)

Kauj ruam 2: Ua Music Box

Ua Music Box
Ua Music Box
Ua Music Box
Ua Music Box

Cov lus qhia dav dav muaj nyob rau ntawm AdaFruit qhov chaw ntawm

Ib qho tseem ceeb yuav tau xyuam xim rau:

Thaum nyeem dhau AdaBox004 cov lus qhia nws yooj yim rau kev hla mus rau qhov chaw qhia rau cov khoom siv. Nco ntsoov them sai sai rau lub thawv ntsuab uas muaj txuas rau: Adafruit Feather HUZZAH ESP8266 (https://learn.adafruit.com/adafruit-feather-huzzah-esp8266). Hauv qab "Siv Arduino IDE" ntu rau pawg thawj coj nws tau txuas rau cov tsav tsheb koj yuav xav tau txuas lub rooj tsavxwm thiab rub tawm cov cai los ntawm Arduino IDE, nrog rau cov lus qhia ntxiv rau pawg thawj coj raws li kev xaiv rau Arduino IDE.

Ib yam li xyuam xim rau qhov txuas rau Music Maker FeatherWing (https://learn.adafruit.com/adafruit-music-maker-featherwing/). Uas muaj cov lus qhia rau txhim kho cov tsev qiv ntawv tsim nyog rau Arduino.

Kuv xaim lub hwj chim ntsuas qhov tseeb raws li qhia (https://learn.adafruit.com/adabox004/adding-a-volume-knob)-tab sis nco ntsoov tias kuv tau txav Tsiaj ntxiv rov qab rau ntawm lub khob cij kom tau txais USB cable kom haum.

Lub thawv dawb los nrog cov khoom siv. Kuv yooj yim siv lub qhov xaum txhawm rau ua qhov loj txaus rau suav nrog USB cable kom haum los ntawm. Kuv tau ua qhov me me nrog rab riam hnab tshos rau hauv lub thawv ntawv kom kuv thiaj paub qhov twg ntawm txhua lub vaj huam sib luag los txiav.

Txog rau tus hais lus qhib, Kuv kwv yees lub hauv paus thiab cim nws nrog cov npib txawv teb chaws loj (Costa Rican 100 colones kom raug), tom qab ntawd txiav lub voj voog nrog rab hobby khw. Tus hais lus tau teeb tsa thiab kuv cim qhov twg cov ntsia hlau me me yuav tsum mus nrog qhov xaum nrig.

Kauj ruam 3: Music Player Code

Kuv hloov tus lej piv txwv rau tus neeg siv plaub, tshem tawm cov cai uas tsis siv. Koj tuaj yeem txiav-thiab-muab nws tso rau hauv Arduino IDE tom qab ntawd thauj nws mus rau koj cov plaub hau.

Nco ntsoov tias kuv tau siv sijhawm nyuaj kom tau txais cov ntaub ntawv kom raug lees paub. Qhov kuv muaj ntawm no ua haujlwm, tab sis koj yuav tsum kho qhov chaws kom hloov cov nkauj uas muaj. Thiab nco ntsoov tias txoj kev uas kuv tau ua nws yuav ua rau nyuaj ua dhau 100 zaj nkauj (000 - 099) vim nws tsuas yog xaiv 2 tus lej xwb. Kuv tuaj yeem xaiv tus lej taug qab tiag, tab sis tom qab ntawd yuav tsum tau cais nws los tsim lub npe cov ntaub ntawv raug. Tej zaum hauv qee qhov kev rov ua dua yav tom ntej.

Cov ntaub ntawv tseem muaj nyob ntawm GitHub ntawm https://github.com/KFW/AdaBox004. Yog tias kuv hloov pauv, qhov ntawd yog qhov lawv yuav nyob.

// AdaBox004_random_songs

// Tshwj xeeb rau siv nrog Adafruit Feather, cov pins tau npaj ua ntej ntawm no! // hloov pauv feather_player piv txwv rau AdaBox 004 project // standalone player uas ua nkauj tsis raug cai los ntawm playlist // stripped out unused code // muaj teeb meem tau txais cov ntaub ntawv npe txoj hlua los ua haujlwm hloov txoj hlua // vim tias muaj nuj nqi hu rau kev ua si siv kab array // tom qab sim sib txawv txoj hauv kev no yog kludge Kuv tuaj nrog // kab ntawv muaj npe TRACK ##. mp3 // Kuv muaj 60 nkauj ntawm SD card Kuv m siv (000 - 059) // yuav tau ntse dua los suav # ntawm cov ntaub ntawv lossis nrhiav lwm txoj hauv kev kom tau txais lub npe cov ntawv tsis raug // Oh zoo rau lub sijhawm tom ntej

// suav nrog SPI, MP3 thiab SD cov tsev qiv ntawv

#include #include #include

// Cov no yog cov pins siv

#define VS1053_RESET -1 // VS1053 pib dua tus pin (tsis siv!) // Plaub ESP8266 -siv HUZZAH featther #define VS1053_CS 16 // VS1053 nti xaiv tus pin (tso tawm) #define VS1053_DCS 15 // VS1053 Cov ntaub ntawv/hais kom xaiv tus pin (output) #define CARDCS 2 // Card chip xaiv tus pin #define VS1053_DREQ 0 // VS1053 Cov ntaub ntawv thov, hom phiaj cuam tshuam tus pin #define VOLUME_KNOB A0

int lastvol = 10;

int loopcounter = 0; ntev trackNumber; Txoj hlua trackString; char song [13] = {'T', 'R', 'A', 'C', 'K', '0', '2', '0', '.', 'm', 'p', '3', '\ 0'};

Adafruit_VS1053_FilePlayer musicPlayer =

Adafruit_VS1053_FilePlayer (VS1053_RESET, VS1053_CS, VS1053_DCS, VS1053_DREQ, CARDCS);

void teeb tsa () {

// Serial.begin (115200); // tsuas yog xav tau rau teeb meem tua // thaum (! Serial) {ncua (1); } // Tos rau qhov chaw nres nkoj txuas tau qhib, // Serial.println ("\ n / n Adafruit VS1053 Feather Test"); randomSeed (ESP.getCycleCount ()); // HUZZAH tsuas muaj 1 tus pin analog uas twb tau siv lawm // xav tau cov noob sib txawv // lub tswv yim no los ntawm https://github.com/esp8266/Arduino/issues/728 musicPlayer.begin (); musicPlayer.sineTest (0x44, 500); // Ua lub suab los qhia VS1053 ua haujlwm SD.begin (CARDCS);

// Teeb ntim rau sab laug, txoj cai. tus lej qis == nrov dua!

musicPlayer.setVolume (lastvol, lastvol); musicPlayer.useInterrupt (VS1053_FILEPLAYER_PIN_INT); // DREQ koj}

void voj () {

// kos ib ntus los kho qhov ntim!

loopcounter ++; yog (loopcounter> = 1000) {loopcounter = 0; int vol = 0; vol = analogRead (VOLUME_KNOB); vol /= 10; yog (abs (vol - lastvol)> 3) {// Serial.println (vol); lastvol = vol; musicPlayer.setVolume (lastvol, lastvol); }}

// Ua si cov ntawv hauv keeb kwm yav dhau, thov cuam tshuam!

yog (! musicPlayer.playingMusic) {trackNumber = random (6); // yuav tsum ua tus lej no ib zaug; thawj tus lej 0-5 char c = char (trackNumber + 48); // ASCII 48 yog '0'; yuav tsum tau hloov tus nqi kom tau txoj nkauj zoo nkauj [6] = c; // hloov kaum tus nqi hauv char kab trackNumber = random (10); // tus lej thib ob 0-9 c = char (trackNumber + 48); nkauj [7] = c; // Serial.println (nkauj); musicPlayer.startPlayingFile (nkauj); ncua (10); }}

Kauj ruam 4: Txaus siab rau

Cias ntsaws rau hauv USB fais fab mov thiab txaus siab rau koj cov nkauj nyiam.

Lub ntim tuaj yeem hloov kho nrog lub hwj chim hauv lub thawv. Txwv tsis pub tsis muaj kev tswj hwm.

Pom zoo: