Cov txheej txheem:

Ua Si Nkauj Nrog Arduino!: 5 Kauj Ruam (nrog Duab)
Ua Si Nkauj Nrog Arduino!: 5 Kauj Ruam (nrog Duab)

Video: Ua Si Nkauj Nrog Arduino!: 5 Kauj Ruam (nrog Duab)

Video: Ua Si Nkauj Nrog Arduino!: 5 Kauj Ruam (nrog Duab)
Video: Ntsuag xyoob Arkansas 2024, Kaum ib hlis
Anonim
Ua Si Nkauj Nrog Arduino!
Ua Si Nkauj Nrog Arduino!

Hauv cov lus qhia no kuv yuav qhia koj li cas kuv ua suab paj nruag siv Arduino UNO thiab SD Card module.

Peb yuav siv SPI Kev Sib Txuas Lus.

Cia peb pib!

Kauj Ruam 1: Qhov Chaw

Qhov
Qhov

Peb yuav xav tau cov hauv qab no:

Arduino UAS

SD Card Nyeem Ntawv

Jumper Hlau

Suab Amplifier

Hais lus

Kauj ruam 2: Code

Code
Code

Cov cai nws yooj yim heev, koj tuaj yeem siv nws los ua suab nkauj zoo nkauj uas nyob hauv SD Card tab sis nrog cov hom tshwj xeeb, uas yog nyob rau theem tom ntej.

Koj yuav tsum rub tawm txhua lub tsev qiv ntawv frist, yog tias koj twb muaj nws ces tsuas yog luam thiab muab tshuaj txhuam:

#suav nrog "SD.h" // SD tsev qiv ntawv#txhais SD_ChipSelectPin 4 // Xaiv tus lej SS rau SD module

#suav nrog "SPI.h"

#suav nrog "TMRpcm.h" // Lub tsev qiv ntawv los ua cov ntaub ntawv audio

TMRpcm Nco; // Ntawm no koj tso lub npe koj xav tau

void teeb tsa () {

Serial.begin (9600); // Pib serial com

yog tias (! SD.begin (SD_ChipSelectPin)) {// Yog tias tus lej SS nyob hauv lub xeev LOW nws yuav xa lus tsis pom Serial.println ("SD tsis ua");

rov qab;

}

Memoria.speakerPin = 9; // Tus pin uas koj yuav tso tus hais lus, feem ntau yog 9

}

void voj () {

Memoria.setVolume (5); // Koj tuaj yeem teeb lub ntim ntawm no txog 7

Memoria.quality (1); // tsuas yog lees txais 1 lossis 0, 1 yog rau qhov ua tau zoo dua

Memoria.play ("1.wav"); // Ntawm no koj tso lub npe ntawm koj lub suab

ncua (10000); // Qhov kev ncua no yuav tsum yog yam tsawg ib yam ntawm koj lub suab, // Lub tsev qiv ntawv no tuaj yeem ua suab paj nruag thaum lub arduino nyob hauv lwm txoj haujlwm yog li koj tuaj yeem ua nws keeb kwm yav dhau

// lossis tos kom lub suab tiav

}

Kauj ruam 3: Hloov Cov Ntaub Ntawv Suab

Hloov Cov Ntaub Ntawv Suab
Hloov Cov Ntaub Ntawv Suab
Hloov Cov Ntaub Ntawv Suab
Hloov Cov Ntaub Ntawv Suab

Qhov no yuav ua haujlwm nrog.wav cov ntaub ntawv audio tab sis koj yuav tsum ua som kev txiav txim siab rau nws.

Rau qhov ntawd koj tuaj yeem siv cov hloov pauv online hauv qab no.

audio.online-convert.com/convert-to-wav

Yog li, hauv nplooj ntawv no koj yuav tsum hloov pauv qhov chaw zoo li tau qhia hauv daim duab ces koj tsuas yog nyem rau hauv "Hloov Cov Ntaub Ntawv" thiab tos kom txog thaum hloov pauv tau ua tiav thiab rub tawm cov ntawv tshiab!

Tom qab ntawd koj yuav tsum tso tag nrho cov ntaub ntawv audio no rau ntawm daim npav SD thiab ntsaws nws rau hauv cov qauv arduino.

Kuj tseem muaj lwm qhov tshwj xeeb ntawm lub tsev qiv ntawv no zoo li hauv daim duab saum toj no yog li koj tuaj yeem siv nws thiab ua lub tshuab ntaus nkauj nrog cov nyees khawm rau ntim, nkauj tom ntej thiab lwm yam, thiab lwm yam zoo li koj xav tau! Ntuj yog qhov txwv!

Kauj ruam 4: Daim duab

Daim duab
Daim duab

Nov yog tus pin teeb rau arduino thiab SD module:

Arduino >>>>>>> SD Module

4 >>>>>>>>>>>> SSS

11 >>>>>>>>>> MOSI

12 >>>>>>>>>> MISO

13 >>>>>>>>>> SCK

5v >>>>>>>>>> 5v

Gnd>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> thiab tshaj thiab zoo tshaj, Gnd

9 >>>>>>>>>> PWM Audio Out

Lub suab tso tawm tuaj yeem txuas nrog lub suab hais lus nrov nrov vim tias lub zog qis, thiab kev siv kom raug tuaj yeem ua rau arduino puas tsuaj yog tias koj txuas ncaj qha.

Thiab … koj ua tiav!

Qhia rau kuv paub yog tias koj muaj kev ua xyem xyav, Kuv yuav zoo siab los teb, Ua tsaug rau kev nyeem kuv instrctable!

Kauj Ruam 5: Cov txiaj ntsig

Cov txiaj ntsig
Cov txiaj ntsig

Yog tias koj muaj lub osciloscope koj yuav tsum tuaj yeem pom PWM teeb liab ntawm lub suab tso tawm zoo li no.

Thiab … koj ua tiav!

Qhia rau kuv paub yog tias koj muaj kev ua xyem xyav, Kuv yuav zoo siab los teb, Ua tsaug rau kev nyeem kuv cov lus qhia!

Pom zoo: