Cov txheej txheem:
- Kauj Ruam 1: Teeb Kho Vajtse
- Kauj ruam 2: Teeb Software
- Kauj ruam 3: Hloov kho
- Kauj Ruam 4: Ntau Yam Haujlwm
Video: Arduino Doorbell: 4 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:24
Hnub no, kuv yuav qhia koj yuav ua li cas ua lub tswb qhov rooj siv Arduino. Lub pob qhov rooj no ua suab tsis zoo los ntawm lub tsev qiv ntawv nkauj. Koj tuaj yeem hloov kho koj lub qhov rooj thiab ntxiv cov nkauj ntau dua. Nruab nws sab nraum koj chav pw, chav kawm, chaw ua haujlwm, lossis txawm tias koj lub qhov rooj!
Khoom siv:
- Arduino Uno (feem ntau lwm hom yuav ua)
- Khoos phis tawj nrog Arduino IDE rau kev ua haujlwm
- USB-A rau USB-B cable rau programming Arduino
- Cov qhob cij
- 4x jumper kab
- Pushbutton lossis lwm yam hloov
- 10 kOhm Resistor
- Passive buzzer (piv txwv li piezoelectric hais lus)
-
Rau kev teeb tsa ruaj khov:
- 9V DC Cov Khoom Siv Hluav Taws Xob lossis 9V roj teeb rau lub zog Arduino
- 2x ntev xov hlau rau khawm khawm sab nraum lub qhov rooj
Kauj Ruam 1: Teeb Kho Vajtse
Ua ntej, peb yuav teeb kho vajtse. Peb yuav pib nrog passive buzzer (piv txwv li hais lus). Peb xav txuas qhov zoo kawg ntawm tus passive buzzer (qhia los ntawm "+" kos npe) rau digital pin 8 ntawm Arduino. Peb yuav txuas rau lwm qhov kawg ntawm tus passize buzzer rau hauv av.
Tom ntej no, peb yuav nruab lub laub khawm rau lub qhov rooj. Peb yuav siv 10 kOhm sab nraud pulldown resistor rau qhov hloov pauv, yog li tsis muaj qhov hluav taws xob ntab lossis lub xeev tsis ruaj khov ntawm kev nkag mus rau Arduino. Los ntawm kev siv lub zog tiv thaiv kab mob, Arduino nyeem qhov hluav taws xob li 0V thaum lub pob tsis tau nyem thiab 5V thaum lub pob nyem. Yog xav paub ntau ntxiv txog kev rub tawm lossis rub tawm tus tiv thaiv, koj tuaj yeem nyeem kab ntawv no:
Peb yuav txuas ib sab ntawm lub laub khawm mus rau 5V. Lwm sab ntawm lub laub khawm yuav txuas nrog hauv av los ntawm 10 kOhm pulldown resistor. Nco ntsoov: cov khawm laub tau txuas nrog kab rov tav sab hauv. Lawv tsuas yog txuas nrog ntsug thaum nias. Xav paub ntau ntxiv hauv kab lus no:
Kauj ruam 2: Teeb Software
Txhua qhov chaws tau txuas nrog. Hauv qab no yog cov lus piav qhia ntawm txhua qhov kev ua haujlwm nrog snapshots ntawm cov cai.
teeb:
Hauv kev teeb tsa () muaj nuj nqi, peb xav teeb tsa lub koob digital rau peb lub pob thiab peb tus hais lus. Peb xav teeb tsa tus pin 2 ua lub tswv yim rau peb lub pob, thiab peb xav teeb tsa tus pin 8 ua qhov tso tawm rau peb tus neeg hais lus.
Peb kuj xav "noob" peb tus lej tooj tsim hluav taws xob rau xaiv xaiv lub suab thaum ib tus neeg hu xov tooj rau peb lub qhov rooj. Seeding peb tus lej xov tooj sib piv txhais tau tias pub nws nkag mus tsis raug. Peb yuav cog peb lub tshuab hluav taws xob tus lej sib piv nrog tus nqi hluav taws xob ntawm analog input 0. Txij li tsis muaj dab tsi txuas nrog cov tswv yim no, yuav muaj "random", hloov pauv qhov hluav taws xob ntawm tus pin no muab peb lub tshuab hluav taws xob tus lej nrog ntau qhov sib txawv. Qhov no ua kom ntseeg tau tias peb yuav muaj qhov sib txawv ntawm kev xaiv nkauj rau peb lub tswb. Yog xav paub ntxiv txog Arduino random () muaj nuj nqi, mus ntawm no:
#suav nrog "pitches.h"
#include "songs.h" #define BUTTON_PIN 2 #define SPEAKER_PIN 8/ * teeb tsa muaj nuj nqi */tsis muaj teeb meem teeb tsa () {// pab kom nkag tau/tso zis pins pinMode (BUTTON_PIN, INPUT); tus pinMode (SPEAKER_PIN, OUTPUT); // noob random () ua haujlwm kom peb tau txais qhov kev txiav txim sib txawv randomSeed (analogRead (0)); }
voj:
Hauv peb lub voj () muaj nuj nqi, peb yuav txuas ntxiv mus saib seb lub pob raug nias (tus lej digital 2 siab dua). Yog tus pin siab, peb tos 50 ms thiab rov xyuas dua kom paub tseeb tias nws tseem siab. Qhov no ua kom ntseeg tau tias lub khawm tau nias thiab nws tsis muaj suab nrov los ntawm tus lej nkag digital ua rau muaj qhov tsis raug.
Thaum peb tau lees paub tias khawm tau raug nias, peb siv peb lub tshuab hluav taws xob tus lej xaiv los xaiv ib qho ntawm 5 zaj nkauj siv cov lus hloov pauv. Cov ntaub ntawv rau cov nkauj no tau khaws cia hauv "nkauj.h" thiab cov ntaub ntawv suab tau khaws cia hauv "pitches.h". Thaum peb xaiv ib zaj nkauj, peb dhau cov ntaub ntawv no mus rau hauv kev ua haujlwm play_song ().
/ * lub ntsiab thaum lub sijhawm ua haujlwm */
lub voj void () {// xyuas seb puas tau khawm yog tias (digitalRead (BUTTON_PIN) == HIGH) {// ncua 50 ms kom paub tseeb tias nws tseem raug nias // zam kev yuam kev yuam kev yuam kev qeeb (50); yog (digitalRead (BUTTON_PIN) == HIGH) {// xaiv ib zaj nkauj int song_choice = random (5); // xaiv cov nkauj twg los hloov pauv (nkauj_choice) {rooj plaub 0: play_song (txiav plaub hau ntev, txiav plaub hau, txiav plaub hau, txiav plaub hau) tawg; rooj plaub 1: play_song (marioLength, mario, marioDurations, marioTempo); tawg; rooj plaub 2: play_song (miiLength, mii, miiDurations, miiTempo); tawg; rooj plaub 3: play_song (hpLength, hp, hpDurations, hpTempo); tawg; rooj plaub 4: play_song (takeonmeLength, takeonme, takeonmeDurations, takeonmeTempo); tawg; default: play_song (miiLength, mii, miiDurations, miiTempo); tawg; }}}}
play_song:
play_song () siv 4 qhov kev sib cav: tus lej naj npawb ntawm cov ntawv hauv zaj nkauj, cov lej sib xyaw ntawm cov suab hauv suab paj nruag, cov lej sib xyaw ntawm lub sijhawm, thiab cov lej sib xws rau cov nkauj tshwj xeeb. Koj yuav tsum qhia txhua qhov ntawm no rau txhua zaj nkauj koj xav ua si. Yog xav paub ntau ntxiv txog yuav siv lub suab Arduino li cas, koj tuaj yeem saib ntawm qhov kev qhia no: https://www.arduino.cc/en/Tutorial/ToneMelody. Kuv tau ntxiv qee qhov ua haujlwm nyob rau sab saum toj ntawm cov ntawv qhia no rau cov ntawv sau tseg. Yog tias tus nqi hauv daim ntawv teev sijhawm ntev tsis zoo, qhov ntawd txhais tau tias nws yog cov ntawv sau tseg (qhov ntev yog 1.5 npaug ntau dua).
/ * ua zaj nkauj */
void play_song (int num_notes, int melody , int noteDurations , int tempo) {// nqis los thiab ua si tag nrho cov ntawv rau (int i = 0; i 0) {duration = tempo / noteDurations ; } // yog tias nws yog tus lej tsis zoo, txhais tau tias dotted note // nce lub sijhawm ib nrab rau cov ntawv sau tseg yog tias (noteDurations <0) {duration = tempo / abs (noteDurations ) * 1.5; } lub suab (SPEAKER_PIN, suab paj nruag , sijhawm); // kom paub qhov txawv ntawm cov ntawv, teem sijhawm tsawg kawg ntawm lawv. // qhov kev ceeb toom lub sijhawm + 30% zoo li ua haujlwm tau zoo: int pauseBetweenNotes = sijhawm * 1.30; ncua (pauseBetweenNotes); // nres lub suab ua si: noTone (SPEAKER_PIN); }}
Qauv ntawm nkauj.h:
Hauv qab no yog piv txwv ntawm ib ntawm cov nkauj hauv "songs.h". Cov ntawv yog macros tau hais tseg hauv "pitches.h". Cov lej sib raug rau cov zaus ntawm cov ntawv hauv hertz (Hz). Lub sijhawm sau ntawv tau teev tseg raws li: 1 = tag nrho cov ntawv, 2 = ib nrab ntawv, 4 = daim ntawv qhia peb lub hlis, 8 = daim ntawv thib yim, -4 = daim ntawv teev tseg peb lub hlis, thiab lwm yam. Lub nrawm yog tus faib rau qhov nrawm ntawm zaj nkauj (tus lej siab dua txhais tau tias qeeb qeeb). Koj yuav tsum ua si ib puag ncig nrog tus lej no kom txog thaum koj tau txais lub sijhawm uas koj nyiam.
/ * Harry Potter */
int hp = {NOTE_D4, NOTE_G4, NOTE_AS4, NOTE_A4, NOTE_G4, NOTE_D5, NOTE_C5, NOTE_A4, NOTE_G4, NOTE_AS4, NOTE_A4, NOTE_F4, NOTE_GS4, NOTE_D4}; int hpDurations = {4, -4, 8, 4, 2, 4, -2, -2, -4, 8, 4, 2, 4, 1}; int hpLength = 14; int hpTempo = 1050;
Kauj ruam 3: Hloov kho
Ntxiv nkauj ntxiv! Ua raws li cov qauv pom hauv "songs.h" thiab siv cov lus qhia rau kev pab: https://www.arduino.cc/en/Tutorial/ToneMelody. Rau txhua qhov nkauj tshiab koj ntxiv, nco ntsoov ntxiv cov ntaub ntawv tshiab rau cov lus hloov pauv thiab nce tus lej siab tshaj plaws uas tuaj yeem tsim los ntawm koj qhov kev ua haujlwm random (). Zoo siab coding!
Kauj Ruam 4: Ntau Yam Haujlwm
Yog xav paub ntau ntxiv, mus saib kuv nplooj ntawv:
- https://dargen.io/
- https://github.com/mjdargen
- https://www.instructables.com/member/mjdargen/
Pom zoo:
Arduino Tsheb Rov Qab Chaw Nres Tsheb Ceeb Toom - Cov Kauj Ruam ntawm Kauj Ruam: 4 Kauj Ruam
Arduino Tsheb Rov Qab Chaw Nres Tsheb Ceeb Toom | Cov kauj ruam ib kauj ruam: Hauv txoj haujlwm no, kuv yuav tsim qhov yooj yim Arduino Tsheb Rov Qab Tsheb Nres Tsheb Nres Sensor Siv Arduino UNO thiab HC-SR04 Ultrasonic Sensor. Qhov no Arduino raws Lub Tsheb Rov Qab ceeb toom tuaj yeem siv rau Kev Tshawb Fawb Txog Tus Kheej, Robot Ranging thiab lwm yam
Arduino Coronavirus Doorbell: 6 Kauj Ruam
Arduino Coronavirus Doorbell: Vim tias muaj tus kabmob coronavirus thoob ntiaj teb, kuv xav ua lub tswb qhov rooj uas koj tsis tas yuav nias lub cim rau cov neeg sab hauv uas koj nyob ntawm no thiab lawv yuav tsum qhib qhov rooj. Qhov no tuaj yeem ua rau koj kis tus kabmob los ntawm kev kov lwm tus neeg lub qhov rooj
Arduino Doorbell: 5 Kauj Ruam
Arduino Doorbell: SUPPLIES-2 qhob cij board-buzzer-jumper xov hlau-2 arduino/genuino nrog lub zog fais fab-rf tus xa xov thiab tus txais-thawb khawm -100 ohm resistor
RC Taug Qab Neeg Hlau Siv Arduino - Kauj Ruam Ib kauj ruam: 3 Kauj Ruam
RC Tracked Robot Siv Arduino - Kauj Ruam Ib Nrab: Hav guys, Kuv rov qab los nrog lwm tus neeg hlau txias chassis los ntawm BangGood. Vam tias koj tau dhau los ntawm peb cov phiaj xwm yav dhau los - Spinel Crux V1 - Tus Cwj Pwm Tswj Tus Neeg Hlau, Spinel Crux L2 - Arduino Xaiv thiab Muab Neeg Hlau nrog Robotic caj npab thiab Badland Braw
DIY Arduino Robotic Arm, Kauj Ruam ntawm Kauj Ruam: 9 Kauj Ruam
DIY Arduino Robotic Arm, Kauj Ruam ntawm Kauj Ruam: Cov ntawv qhia no yog qhia koj yuav tsim lub Caj Npab Caj Npab ntawm koj tus kheej li cas