Cov txheej txheem:

Nyiaj Heist BELLA CIAO Nkauj hauv Arduino Uno: 9 Kauj Ruam (nrog Duab)
Nyiaj Heist BELLA CIAO Nkauj hauv Arduino Uno: 9 Kauj Ruam (nrog Duab)

Video: Nyiaj Heist BELLA CIAO Nkauj hauv Arduino Uno: 9 Kauj Ruam (nrog Duab)

Video: Nyiaj Heist BELLA CIAO Nkauj hauv Arduino Uno: 9 Kauj Ruam (nrog Duab)
Video: lub walk Band kuj ua nkauj zoo kawg tab mas qeeb heev 2024, Hlis ntuj nqeg
Anonim
Image
Image

Hauv qhov kev qhia no, kuv yuav qhia koj li cas koj tuaj yeem ua si Money Heist Song Bella Ciao hauv ib qho Arduino nrog kev pab ntawm Piezoelectric buzzer. Txoj haujlwm txias no tau mob siab rau txhua tus Money Heist cov kiv cua thoob plaws ntiaj teb. Yog li, Cia peb pib.

Khoom siv

Kho vajtse

  • Arduino Ib
  • Piezoelectric Buzzer
  • USB A rau B Cable

Software

Arduino IDE Cov

Code thiab Circuit

Rub tawm Txoj Cai los ntawm peb GitHub Repository

Kauj ruam 1: Arduino yog dab tsi?

Arduino yog lub platform siv hluav taws xob qhib raws qhov yooj yim-rau-siv-kho vajtse thiab software. Cov laug cam Arduino tuaj yeem nyeem cov tswv yim - teeb ntawm lub ntsuas pa, ntiv tes ntawm lub pob, lossis Twitter lus - thiab tig nws mus rau hauv cov zis - qhib lub tshuab, qhib lub LED, tshaj tawm qee yam online. Koj tuaj yeem qhia koj pawg thawj coj ua dab tsi los ntawm kev xa cov txheej txheem qhia rau microcontroller ntawm lub rooj tsavxwm. Txhawm rau ua li ntawd koj siv Arduino cov lus programming (raws li thaiv), thiab Arduino Software (IDE), raws li Kev Ua Haujlwm.

Xyoo dhau los Arduino yog lub hlwb ntawm ntau txhiab txoj haujlwm, los ntawm cov khoom niaj hnub mus rau cov cuab yeej siv txuj ci nyuaj. Lub zej zog thoob ntiaj teb ntawm cov neeg tsim khoom - cov tub ntxhais kawm, cov nyiam ua haujlwm, cov kws ua yeeb yam, cov kws tsim tawm, thiab cov kws tshaj lij - tau sib sau ua ke nyob ib puag ncig lub platform qhib no, lawv txoj kev koom tes tau ntxiv mus rau qhov tsis txaus ntseeg ntawm kev nkag tau yooj yim uas tuaj yeem pab tau zoo rau cov neeg tshiab thiab cov kws tshaj lij ib yam.

Kauj ruam 2: Arduino UNO

Piezoelectric Buzzer
Piezoelectric Buzzer

Arduino UNO yog pawg thawj coj saib xyuas zoo tshaj plaws kom pib siv hluav taws xob thiab cim npe. Yog tias qhov no yog thawj qhov koj tau ntsib nrog lub platform, UNO yog pawg thawj coj uas muaj zog tshaj plaws uas koj tuaj yeem pib ua si nrog. UNO yog qhov siv ntau tshaj plaws thiab teev tseg pawg thawj coj ntawm tag nrho tsev neeg Arduino.

Arduino Uno yog lub microcontroller board raws li ATmega328P (cov ntawv). Nws muaj 14 digital input/output pins (ntawm uas 6 tuaj yeem siv ua PWM tawm), 6 analog inputs, 16 MHz ceramic resonator (CSTCE16M0V53-R0), USB txuas, txuas lub hwj chim, ICSP header thiab khawm rov pib dua. Nws muaj txhua yam xav tau los txhawb lub microcontroller; yooj yim txuas nws mus rau lub khoos phis tawj nrog USB cable lossis txuas nws nrog AC-rau-DC adapter lossis roj teeb kom pib.. Koj tuaj yeem tinker nrog koj Uno yam tsis muaj kev txhawj xeeb ntau txog kev ua qee yam tsis raug, qhov xwm txheej tsis zoo koj tuaj yeem hloov pauv nti rau ob peb daus las thiab pib dua.

Kauj Ruam 3: Piezoelectric Buzzer

Lub piezo buzzer yog lub tshuab ua suab nrov. Lub hauv paus ntsiab lus ua haujlwm yog ua raws txoj kev xav uas, thaum twg los xij muaj peev xwm siv hluav taws xob hla cov khoom piezoelectric, qhov hloov pauv siab tau tsim. Piezo buzzer muaj piezo muaju nyob nruab nrab ntawm ob tus neeg ua haujlwm. Thaum qhov muaj peev xwm sib txawv tau siv thoob plaws cov muaju no, lawv thawb ib tus neeg coj thiab rub lwm tus neeg coj los ntawm lawv cov khoom ntiag tug. Kev rub thiab thawb txuas ntxiv ua kom muaj suab nrov nthwv dej. Piezo buzzers tsim lub suab nrov & ntse. Yog li, lawv feem ntau siv los ua lub tswb ntsuas hluav taws xob. Tsis tas li, lawv tau siv los ceeb toom ntawm ib qho xwm txheej, teeb liab lossis cov tswv yim nkag. Cov yam ntxwv tshwj xeeb ntawm piezo buzzer yog, lub suab suab lossis qib tsis nyob ntawm qhov ntsuas hluav taws xob uas yog, nws ua haujlwm tsuas yog nyob hauv qhov tshwj xeeb qhov hluav taws xob. Feem ntau, piezo buzzer tuaj yeem tsim lub suab hauv thaj tsam ntawm 2 txog 4 kHz.

Kauj Ruam 4: Yuav Ua Li Cas Sau Ntawv?

Ua ntej tshaj plaws peb yuav tsum txheeb xyuas cov zaus ntawm cov ntawv (zoo siab tau hnov) nrog "int" ua haujlwm. Tom qab ntawv txheeb xyuas tus nqi ntawm BPM (Koj tuaj yeem hloov kho nws pom tseeb) thiab raws li qhov ntawd txhais cov lus ceeb toom.

int rounda = 0; int puag ncig = 0; int dawb = 0; int whitep = 0; int dub = 0; blackp cov = 0; int cov = 0; int cov = 0; int ib nrab = 0; int semiquaverp = 0;

Tom qab ntawd kuv tau piav qhia tus nqi ntawm BPM (koj tuaj yeem hloov kho nws pom tseeb).

pem bpm = 120;

Raws li tus nqi txhais ntawm BPM txhais cov lus ceeb toom.

dub = 35000/bpm; blackp = dub*1.5; dawb = dub*2; whitep = dawb*1.5; puag ncig = dub*4; puag ncig = puag ncig*1.5; quaver = dub/2; quaverp = qua*1.5; semiquaver = dub/4; semiquaverp = ib nrab*1.5;

Nrog rau cov txiaj ntsig tau teev tseg no koj tuaj yeem yooj yim ua cov ntawv nrog cov lus txib "suab" zoo li no.

laus (tus pin, nco tseg, sijhawm);

Hauv txoj haujlwm no, peb siv tib txoj hauv kev.

suab nrov (BuzzerPin, Mi, dub); ncua (dub+50);

Txoj kev no, Kuv tau ua suab nkauj rau Bella Ciao Nkauj. Qhov ntawd yog txhua yam hais txog txoj cai.

Sim sau cov cai koj tus kheej. zam kev luam daim ntawv.

Cia peb upload cov cai rau peb pawg Arduino tam sim no.

Kauj Ruam 5: Tshaj Tawm Txoj Cai rau Arduino

Upload Code rau Arduino
Upload Code rau Arduino
Upload Code rau Arduino
Upload Code rau Arduino

Qhib cov cai hauv Arduino Software. Xaiv tus qauv ntawm Pawg Thawj Coj uas koj siv. Ntawm no kuv yuav mus nrog Arduino Uno. Txhawm rau xaiv lub rooj tsavxwm, Mus rau "Cov Cuab Yeej> Boards".

Tam sim no, Xaiv Chaw Nres Nkoj uas koj Arduino txuas nrog. xaiv qhov chaw nres nkoj, mus rau "Cuab Yeej> PORT".

Tom qab xaiv qhov raug lawm, Nyem rau Upload Button txhawm rau upload cov cai rau Arduino.

Kauj Ruam 6: Txuas Buzzer Nrog Arduino

Txuas Buzzer Nrog Arduino
Txuas Buzzer Nrog Arduino

Peb tau ua tiav cov phiaj xwm peb lub microcontroller los ua si Bella ciao Notes. Tam sim no peb yuav tsum txuas Piezo Buzzer kom hnov lub suab nkauj. Yog li, Txuas Cov Hluav Taws Xob liab ntawm Piezo Buzzer mus rau 11 th Pin ntawm Arduino Uno thiab Cov Hlau Dub rau 'GND' raws li pom hauv daim duab qhia chaw.

Kauj Ruam 7: Yuav Ua Li Cas Thiaj Li Ua Haujlwm Hauv Tinkercad Circuits?

Yuav Ua Li Cas Thiaj Li Ua Haujlwm Hauv Tinkercad Circuits?
Yuav Ua Li Cas Thiaj Li Ua Haujlwm Hauv Tinkercad Circuits?
Yuav Ua Li Cas Thiaj Li Ua Haujlwm Hauv Tinkercad Circuits?
Yuav Ua Li Cas Thiaj Li Ua Haujlwm Hauv Tinkercad Circuits?
Yuav Ua Li Cas Thiaj Li Ua Haujlwm Hauv Tinkercad Circuits?
Yuav Ua Li Cas Thiaj Li Ua Haujlwm Hauv Tinkercad Circuits?

Peb txhua tus raug kaw vim yog COVID19. Yog li tsis txhob txhawj xeeb yog tias koj tsis muaj cov khoom siv tiag. Koj tuaj yeem sim qhov haujlwm no hauv tinkercad circuits thiab nkag siab txog kev ua haujlwm.

Lub taub hau mus rau Tinkercad Lub Vev Xaib los ntawm no. Nyem rau ntawm "JOIN NOW" khawm yog tias koj tseem tsis muaj acoount tseem. Kuv yuav kos npe nrog kuv tus lej ua yav tas los. Thaum koj nyob hauv Tinker cad Dashboard, Nyem rau ntawm 'Circuits' uas pom ntawm sab laug ntawm qhov screen. Nyem rau ntawm Create New Circuit Button. Tam sim no koj txoj haujlwm tshiab tau tsim. Tam sim no tshawb rau Arduino UNO thiab rub nws mus rau lub vijtsam tseem ceeb los ntawm sab xis Bar. Tam sim no, tshawb nrhiav Buzzer thiab rub lub buzzer rau ntawm lub vijtsam tseem ceeb. Tam sim no ua qhov txuas zoo li hauv Daim Duab.

Nyem rau ntu "Code" txhawm rau program koj Arduino. Rho tawm cov Pre-made blocks thiab hloov lub qhov rais los ntawm block hom rau Text Mode. Muab tshuaj txhuam rau hauv txoj cai los ntawm kev hloov pauv cov lej dawb yav dhau los. Tam sim no Nyem rau ntawm Pib Simulation Khawm kom pom koj txoj haujlwm hauv Kev Ua.

Koj tuaj yeem rov tsim kuv qhov project los ntawm txhaj rau ntawm no.

Kauj Ruam 8: Arduino Code

/ * * * Tsim los ntawm Pi BOTS MakerHub * * Email: [email protected] * * Github: https://github.com/pibotsmakerhub * * Copyright (c) 2020 Pi BOTS MakerHub * * WhatsApp: +91 9400 7010 88 * */ int BuzzerPin = 11; // Txuas Buzzer rau Arduino tus pin 11 int Si2 = 1975; int LaS2 = 1864; tau La2 = 1760; sib SolS2 = 1661; ua Sol2 = 1567; int FaS2 = 1479; koj Fa2 = 1396; koj Mi2 = 1318; int ReS2 = 1244; koj Re2 = 1174; DoS2 = 1108; ua Do2 = 1046; // Tsawg Octave int Si = 987; LaS = 932; tau = 880; sib SolS = 830; ua = 783; FaS = 739; pem = 698; kuv = 659; ReS = 622; rov = 587; DoS = 554; ua = 523; // txhais cov ntawv int rounda = 0; int cov = 0; int dawb = 0; int whitep = 0; int dub = 0; blackp cov = 0; int cov = 0; int cov = 0; int ib nrab = 0; int semiquaverp = 0; pem bpm = 120; teeb tsa tsis muaj dab tsi () {pinMode (BuzzerPin, OUTPUT); dub = 35000/bpm; blackp = dub*1.5; dawb = dub*2; whitep = dawb*1.5; puag ncig = dub*4; puag ncig = puag ncig*1.5; quaver = dub/2; quaverp = qua*1.5; semiquaver = dub/4; semiquaverp = ib nrab*1.5; } void loop () {tone (BuzzerPin, Mi, dub); ncua (dub+50); suab (BuzzerPin, La, dub); ncua (dub+50); suab (BuzzerPin, Si, dub); ncua (dub+50); suab nrov (BuzzerPin, Do2, dub); ncua (dub+50); suab (BuzzerPin, La, dub); ncua (2*dawb+50); suab nrov (BuzzerPin, Mi, dub); ncua (dub+50); suab (BuzzerPin, La, dub); ncua (dub+50); suab (BuzzerPin, Si, dub); ncua (dub+50); suab nrov (BuzzerPin, Do2, dub); ncua (dub+50); suab (BuzzerPin, La, dub); ncua (2*dawb+50); suab nrov (BuzzerPin, Mi, dub); ncua (dub+50); suab (BuzzerPin, La, dub); ncua (dub+50); suab nrov (BuzzerPin, Si, dub); ncua (dub+50); suab (BuzzerPin, Do2, dawb*1.3); ncua (2*dub+50); suab (BuzzerPin, Si, dub); ncua (dub+50); suab (BuzzerPin, La, dub); ncua (dub+50); suab (BuzzerPin, Do2, dawb*1.3); ncua (2*dub+50); suab nrov (BuzzerPin, Si, dub); ncua (dub+50); suab (BuzzerPin, La, dub); ncua (dub+50); suab nrov (BuzzerPin, Mi2, dub); ncua (dawb+50); suab nrov (BuzzerPin, Mi2, dub); ncua (dawb+100); suab nrov (BuzzerPin, Mi2, dub); ncua (dawb+50); suab nrov (BuzzerPin, Re2, dub); ncua (dub+50); suab nrov (BuzzerPin, Mi2, dub); ncua (dub+50); suab nrov (BuzzerPin, Fa2, dub); ncua (dub+50); suab (BuzzerPin, Fa2, dawb*1.3); ncua (puag ncig+100); suab nrov (BuzzerPin, Fa2, dub); ncua (dub+50); suab nrov (BuzzerPin, Mi2, dub); ncua (dub+50); suab nrov (BuzzerPin, Re2, dub); ncua (dub+50); suab nrov (BuzzerPin, Fa2, dub); ncua (dub+50); suab nrov (BuzzerPin, Mi2, dawb*1.3); ncua (puag ncig+100); suab nrov (BuzzerPin, Mi2, dub); ncua (dub+50); suab nrov (BuzzerPin, Re2, dub); ncua (dub+50); suab nrov (BuzzerPin, Do2, dub); ncua (dub+50); suab nrov (BuzzerPin, Si, dawb*1.3); ncua (dawb+50); suab nrov (BuzzerPin, Mi2, dawb*1.3); ncua (dawb+50); suab nrov (BuzzerPin, Si, dawb*1.3); ncua (dawb+50); suab (BuzzerPin, Do2, dawb*1.3); ncua (dawb+50); suab (BuzzerPin, La, rounda*1.3); ncua (puag ncig+50); }

Kauj Ruam 9: Saib Peb Cov Youtube Video

Yog tag nrho. Ua raws li peb rau cov phiaj xwm nthuav dav. Please Ua raws peb ntawm Instagram:

Ua Tsaug.

Pom zoo: