Cov txheej txheem:

Arduino Music Player: 5 Kauj Ruam
Arduino Music Player: 5 Kauj Ruam

Video: Arduino Music Player: 5 Kauj Ruam

Video: Arduino Music Player: 5 Kauj Ruam
Video: Amazing arduino project 2024, Kaum ib hlis
Anonim
Image
Image

Nyob zoo sawv daws.

Nag hmo, Kuv tau caij nthwv dej hauv Is Taws Nem thiab tshawb nrhiav cov haujlwm uas kuv tuaj yeem ua ntawm Arduino. Kuv pom tus poj niam no ua cov keyboard piano hluav taws xob nrog cov nkauj hauv nws. Kuv muaj LCD Keypad Shield dag ib puag ncig yog li kuv xav tias kuv tuaj yeem ua lub tshuab ntaus nkauj uas muaj cov ntawv me me nrog nkauj thiab tus neeg siv tuaj yeem xaiv nws.

Koj tuaj yeem pom qhov kawg ntawm kuv qhov haujlwm saum toj no.

Kauj ruam 1: Yam Koj Yuav Tsum Tau

Yam Koj Yuav Tsum Tau
Yam Koj Yuav Tsum Tau
Yam Koj Yuav Tsum Tau
Yam Koj Yuav Tsum Tau

Rau qhov haujlwm no koj xav tau;

  • Arduino Ib
  • Cov qhob cij
  • LCD Keypad Shield
  • Buzzer
  • 330 ohm tiv thaiv
  • Cov neeg dhia

Kauj Ruam 2: Yam Koj Yuav Tsum Paub

Yam Koj Yuav Tsum Paub
Yam Koj Yuav Tsum Paub

Koj yuav tsum paub me ntsis txog tus qauv ntawm LCD Keypad Shield. Kuv muab lub pinout ntawm nws kom koj tuaj yeem pom dab tsi yog dab tsi.

Raws li koj yuav pom hauv cov cai; tus lej 4, 5, 6, 7, 8 thiab 9 tau siv los ntawm LCD. Pin 10 yog rau kev tswj lub teeb pom kev ntawm LCD tab sis koj yuav tsis xav tau Hauv Circuit Court, cov nyees khawm txuas nrog A0 tus pin.

Qhov ntawd ua rau peb nrog cov pins digital 0, 1, 2, 3, 11, 12, 13 thiab analog pins A1, A2, A3, A4, A5 dawb.

Tsis tas li koj yuav tsum paub qhov sib piv qhov tseem ceeb ntawm txhua lub pob kom koj tuaj yeem txheeb xyuas lawv. Kuv nyeem A0 tus nqi thiab luam tawm ntawm cov ntawv xov xwm kom paub. Nov yog tus qauv piv txwv:

int btn_value = 0;

teeb tsa tsis muaj dab tsi () {Serial.begin (9600); } tsis muaj dab tsi voj () {btn_value = analogRead (A0); Serial.println (btn_value); }

Nov yog qhov muaj txiaj ntsig uas kuv pom rau kuv daim ntaub thaiv:

  • Txoj cai khawm - 0
  • Khawm Up - 131
  • Khawm Down - 306
  • Khawm Sab laug - 481
  • Xaiv Khawm - 722
  • Tsis muaj khawm - 1023

Kauj Ruam 3: Tsim Circuit Court

Tsim Circuit Court
Tsim Circuit Court
Tsim Circuit Court
Tsim Circuit Court

Lub voj voog yog yooj yim zoo nkauj.

  • Muab koj lub buzzer tso rau ntawm qhov chaw ntawm lub khob cij.
  • Txuas ib sab ntawm 330 ohm resistor rau tus pin tsis zoo ntawm lub buzzer thiab lwm sab rau hauv av pin ntawm Arduino.
  • Txuas tus pin zoo ntawm tus buzzer rau tus pin2 ntawm Arduino.

Koj ua tiav lawm! Tam sim no cia peb mus rau qhov coding.

Kauj ruam 4: Code

Thaum koj qhib cov ntawv khaws cia, koj yuav pom cov ntaub ntawv hauv qab no; lcd_keypad_songs, fur_elise, james_bond, jingle_bells, mario_bros_theme, mario_bros_underworld, merry_christmas, pitches.h

  • lcd_keypad_songs yog cov ntaub ntawv tseem ceeb uas cov ntawv qhia zaub mov thiab cov ntsiab lus tau sau. Nws tau sau nrog cov lus kom koj tuaj yeem tshuaj xyuas thiab nkag siab cov cai.
  • pitches.h suav nrog lub ntsiab lus ntawm kev sau nkauj.
  • So ntawm cov ntaub ntawv suav nrog kev ua haujlwm ntawm cov nkauj. Koj tuaj yeem hla dhau lawv thiab sim nkag siab. Kuv tsis tau sau cov lej rau cov nkauj, Kuv pom lawv los ntawm kev tshawb nrhiav. Yog li koj tseem tuaj yeem pom lossis sau koj cov nkauj thiab ntxiv rau hauv cov ntawv qhia zaub mov.

Koj yuav tsum muab lawv tso rau hauv tib daim nplaub tshev. Tom qab ntawd koj yuav tsum qhib lcd_keypad_songs cov ntaub ntawv nrog Arduino IDE thiab xa cov cai.

Nco tseg: james_bond nkauj tsis nyob hauv cov ntawv qhia zaub mov (nws tau hais tawm). Qhov no yog vim tias Arduino muaj qhov txwv tsawg thiab cov nkauj no siv ntau lub cim xeeb. Koj tuaj yeem tsis pom zoo nws thiab tawm tswv yim lwm zaj nkauj los mloog. Koj kuj yuav tsum tau hloov cov ntawv qhia zaub mov.

Kauj ruam 5: Ua tiav

Ua tiav!
Ua tiav!

Nrog koj zoo siab

Koj tau ua nws. Yog tias koj muaj lus nug lossis teeb meem, xav tawm tswv yim lossis xa lus rau kuv. Kuv xav pab.

Zoo Siab Ua!

Pom zoo: