Cov txheej txheem:

Arduino Birthday Cake: 4 Kauj Ruam
Arduino Birthday Cake: 4 Kauj Ruam

Video: Arduino Birthday Cake: 4 Kauj Ruam

Video: Arduino Birthday Cake: 4 Kauj Ruam
Video: Fire truck πŸš’ #youtubeshorts #shorts #fire 2022 watch full vedio #PureNepali πŸ₯ΊπŸ˜’ 2024, Kaum ib hlis
Anonim

Hauv cov lus qhia no, kuv yuav ua qhov yooj yim heev thiab ua haujlwm yooj yim arduino: ncuav mog qab zib hnub yug!

Ib lub ncuav mog qab zib hnub yug tau tshwm ntawm UTFT lub vijtsam tiv thaiv ntawm arduino thiab tus hais lus ua suab paj nruag "Zoo siab hnub yug".

Thaum koj tshuab ntawm lub microphone, tswm ciab tua.

Kauj ruam 1: Cov ntaub ntawv

Khoom siv
Khoom siv
Khoom siv
Khoom siv
Khoom siv
Khoom siv
Khoom siv
Khoom siv

Rau txoj haujlwm yooj yim no, koj yuav xav tau:

- Arduino MEGA

- tus hais lus lossis lub suab nrov

- lub microphone module

- UTFT npo arduino daim thaiv

Kuv txiav txim siab siv daim npav arduino MEGA rau txoj haujlwm no rau ob qho laj thawj: nws muaj lub cim xeeb ntau thiab nws muaj tus pin ntau.

Koj tsis tuaj yeem siv arduino UNO rau txoj haujlwm no, vim tias thaum lub vijtsam UTFT txuas rau nws txhua tus pin tau muab zais (tsis muaj ntxiv rau lub microphone thiab tus hais lus), thiab nws tsis muaj lub cim xeeb txaus (UTFT lub tsev qiv ntawv yog loj heev).

Kauj ruam 2: Kev thaiv kab

Thaiv
Thaiv
Thaiv
Thaiv
Thaiv
Thaiv
Thaiv
Thaiv

Tus hais lus ntsaws rau ntawm tus pin D40 thiab GND ntawm arduino.

Lub microphone ntsaws rau ntawm tus pin GND ("G"), 5V ("+") thiab A10 ("A0").

UTFT lub vijtsam ntsaws zoo li daim ntaub thaiv ib txwm muaj.

UTFT lub vijtsam tiv thaiv tsis tuaj yeem ua tiav nrog arduino MEGA: USB ntsaws ntawm arduino board loj heev

Txhawm rau kho qhov teeb meem no, Kuv tau ntsaws qhov UTFT npo ntawm lwm qhov thaiv arduino (nrog tus pin ntev dua), tom qab ntawd kuv ntsaws ob qho tib si ntawm arduino.

Kauj Ruam 3: Calibrate Microphone

Calibrate lub Microphone
Calibrate lub Microphone
Calibrate lub Microphone
Calibrate lub Microphone

Txhawm rau ntsuas lub microphone, koj yuav xav tau tus ntsia hlau thiab koj lub khoos phis tawj.

Ua ntej tshaj, xa cov cai hauv qab no rau koj arduino:

int tau = 0;

teeb tsa tsis muaj dab tsi () {Serial.begin (9600); } tsis muaj dab tsi voj () {val = analogRead (10); Serial.println (nqi); ncua (100); }

Tom qab ntawd mus rau lub ntsuas saib thiab ntsuas lub microphone los ntawm tig lub hwj chim nrog lub ntswj taub hau thaum tsis muaj lub suab, tus nqi yuav tsum yog kwv yees li 30 ~ 40.

Thaum koj tshuab ntawm lub microphone, tus nqi yuav tsum siab dua 100.

Nco ntsoov tias tus nqi me dua 100 thaum koj hais lus (txawm nrov).

Kauj ruam 4: Txoj Cai

Nov yog txoj cai ntawm txoj haujlwm.

Nws nthuav qhia lub ncuav mog qab zib hnub yug nrog tswm ciab ntawm UTFT thiab ua yeeb yam "Zoo siab hnub yug" nrog tus hais lus. Lub ncuav mog qab zib yog ua nrog cov duab plaub.

Txoj haujlwm no xav tau UTFT lub tsev qiv ntawv.

#suav nrog

sab nrauv uint8_t BigFont ; // hloov cov txiaj ntsig no raws li koj lub vijtsam qauv UTFT myGLCD (ITDB28, A5, A4, A3, A2); int melody = {196, 196, 220, 196, 262, 247, 196, 196, 220, 196, 294, 262, 196, 196, 196, 392, 330, 262, 247, 220, 349, 349, 330, 262, 294, 262}; int noteDurations = {8, 8, 4, 4, 4, 2, 8, 8, 4, 4, 4, 4, 2, 8, 8, 4, 4, 4, 4, 3, 8, 8, 4, 4, 4, 2}; int tau = 0; teeb tsa tsis muaj dabtsis () {myGLCD. InitLCD (); myGLCD.setFont (BigFont); myGLCD.fillScr (20, 200, 150); // xiav keeb kwm yav dhau myGLCD.setColor (200, 125, 50); // ncuav mog qab zib xim av myGLCD.fillRect (100, 90, 220, 160); myGLCD.setColor (255, 255, 255); // dawb icing myGLCD.fillRect (100, 90, 220, 105); myGLCD.setColor (255, 50, 50); // kab liab myGLCD.fillRect (100, 120, 220, 123); myGLCD.fillRect (100, 140, 220, 143); myGLCD.setColor (255, 255, 0); // kab kab daj myGLCD.fillRect (100, 130, 220, 133); myGLCD.setColor (255, 170, 255); // tswm ciab liab myGLCD.fillRect (128, 70, 132, 90); myGLCD.fillRect (158, 70, 162, 90); myGLCD.fillRect (188, 70, 192, 90); myGLCD.setColor (255, 255, 0); // taws tswm ciab myGLCD.fillCircle (130, 62, 5); myGLCD.fillCircle (160, 62, 5); myGLCD.fillCircle (190, 62, 5); myGLCD.setColor (0, 255, 0); // zoo siab hnub yug lus myGLCD.print ("HAPPY BIRTHDAY!", CENTER, 200); rau (int thisNote = 0; thisNote 100) {myGLCD.setColor (20, 200, 150); // tua cov tswm ciab myGLCD.fillCircle (130, 62, 5); myGLCD.fillCircle (160, 62, 5); myGLCD.fillCircle (190, 62, 5); myGLCD.setColor (255, 255, 255); // thiab nthuav tawm "zoo siab" cov lus myGLCD.print ("CONGRATULATIONS !!!", CENTER, 10); ncua (10000); myGLCD.clrScr (); // clear screen tom qab 10s}}

Pom zoo: