Cov txheej txheem:
- Kauj Ruam 1: Yam Khoom Siv Hauv Txoj Haujlwm no
- Kauj Ruam 2: Kev Kho Vajtse Txuas
- Kauj ruam 3: Software Programming
- Kauj ruam 4: Kev ua haujlwm
Video: Christmas Music Cheer Light: 4 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:27
Zoo siab heev Christmas! Koj puas xav muaj tsob ntoo Christmas uas tuaj yeem cuam tshuam nrog koj?
Kauj Ruam 1: Yam Khoom Siv Hauv Txoj Haujlwm no
Cov khoom siv kho vajtse
- Seeeduino V4.2
- Lub hauv paus ntaub thaiv npog V2
- Grove - Hloov kho PIR Tsab Ntawv Pom Zoo Sensor
- Grove - Lub suab nrov Sensor
- Grove - WS2813 RGB LED Sawb Waterproof - 60 LED/m - 1m
Software apps thiab cov kev pabcuam online
Arduino IDE Cov
Kauj Ruam 2: Kev Kho Vajtse Txuas
Txuas PIR Sensor, Lub Suab nrov Sensor thiab LED sawb rau Base Shield qhov chaw nres nkoj D2, A0 thiab D6 cais. Plug Base Shield rau Seeduino, txhua yam ua tiav.
Kauj ruam 3: Software Programming
Cov tsev qiv ntawv hauv qab no xav tau los teeb tsa ua ntej ua haujlwm, thov rub tawm thiab xa lawv mus rau koj Arduino IDE tus kheej:
- Coj_Strip
- MsTimer2
- Arduino_Vector
Txhawm rau ua kom txoj cai nruj dua, peb tau ntim nws. CheerLight chav kawm yog chav kawm thov ntawm txoj haujlwm no.
daim ntawv thov chav kawm:: CheerLight
: pej xeem daim ntawv thov:: interface:: IApplication {pej xeem: teeb tsa teeb tsa (tsis muaj dab tsi); void voj (tsis muaj dab tsi); void setPIRSensorPin (uint8_t tus pin); void setLoudnessSensorPin (uint8_t tus pin); void measureSensors (tsis muaj dab tsi); tsis muaj dab tsi pauvAnimation (tsis muaj dab tsi * args); void changeSpeed (tsis muaj dab tsi * args); void changeColor (tsis muaj dab tsi * args); daim ntawv thov zoo li qub:: CheerLight * getInstance (tsis muaj dab tsi); tiv thaiv: tsav tsheb:: LEDStrip _ledStrip; tsav:: PIRSensor _pirSensor; tsav tsheb:: LoudnessSensor _loudnessSensor; uint8_t _animation; middleware:: Delegate _detectedDelegate; middleware:: Delegate _absoluteLoudnessDelegate; middleware:: Delegate _relativeLoudnessDelegate; CheerLight (tsis muaj dab tsi); daim ntawv thov zoo li qub:: CheerLight _instance; };
CheerLight chav kawm tau tsim los ntawm Singleton Patterns, uas txhais tau tias tsuas muaj ib qho piv txwv rau nws, koj tuaj yeem hu rau CheerLight:: getInstance () rau qhov piv txwv ntawd. Yog tias koj qhov kev sib txuas ntawm Sensors sib txawv rau Kev Sib Txuas Kho Vajtse, koj tuaj yeem hloov lawv los ntawm kev hu xov tooj setPIRSensorPin () thiab setLoudnessSensorPin ().
Peb rov hais dua hu xov tooj measureSensors () txoj hauv kev ncua sijhawm los ua cov ntsuas ntsuas lub sijhawm, tab sis hu rau changeAnimation (), changeSpeed () lossis changeColor () cov txheej txheem manually tsis tsim nyog. Lawv yuav raug hu los ntawm Cov Neeg Sawv Cev thaum ntsuas ntsuas.
Tus Neeg Sawv Cev Yog Dab Tsi?
Raws li peb txhua tus paub, peb tuaj yeem tshaj tawm tus lej ua haujlwm thiab ua rau nws taw tes rau txoj haujlwm hauv C:
tsis muaj dab tsi func1 (tsis muaj dab tsi);
void (*pFunc) (tsis muaj dab tsi) = func1;
thiab siv nws los hu lub luag haujlwm nws taw tes rau
pFunc ();
Tab sis muaj qhov sib txawv hauv C ++, yog tias koj sim sau cov cai hauv qab no:
chav kawm A {
pej xeem: tsis muaj dab tsi func1 (tsis muaj dab tsi); }; void (*pFunc) (tsis muaj dab tsi) = & A:: func1;
tus compiler yuav tshaj tawm hom kev hloov pauv yuam kev, ntawm no yog qhov piv txwv raug:
void (A::*pFunc) (tsis muaj dab tsi) = & A:: func1;
Thaum peb sim siv nws los hu txoj kev ntawd, yuam kev dua. Qhov laj thawj rau qhov yuam kev ntawd yog qhov khoom-txheej txheem yuav tsum raug hu los ntawm ib qho khoom. Yog li peb tsim cov khoom kom hu nws:
A ib;
a.*pFunc ();
Lub sijhawm no tsis muaj teeb meem. Yog li muaj Delegate chav kawm hauv Delegate.h.
tus qauv
middleware chav kawm:: Delegate: public middleware:: interface:: IDelegate {public: Delegate (T *object, void (T:: *method) (void *)); void invoke (tsis muaj dab tsi * args); tiv thaiv: T * _object; tsis muaj dab tsi (T:: *_ txoj kev) (tsis muaj *); }; template inline middleware:: Delegate:: Delegate (T *object, void (T:: *method) (void *)): _object (object), _method (method) {} template inline void middleware:: Delegate:: thov (void * args) {(_object-> * _ method) (args); }
Vim tias Delegate chav kawm yog chav kawm qauv, uas txhais tau tias Delegate txawv rau Delegate, yuav ua li cas thiaj ua rau lawv taw qhia los ntawm tus pointer muaj tib yam? Cov lus teb yog interface, yog li muaj IDelegate interface hauv IDelegate.h.
middleware chav kawm:: interface:: IDelegate {
pej xeem: virtual void invoke (void * args) = 0; };
Hauv PIR Sensor thiab Loudness Sensor's chav kawm, muaj qhov sib txawv hu ua _delegates siv los khaws tus pointer ntawm Cov Neeg Sawv Cev, thiab muaj ib txoj hauv kev hu ua invokeAllDelegates () siv los hu rau txhua tus Delegates hauv _delegates, nws yuav raug hu ua ntsuas () txoj hauv kev.
NCO TSEG: Cov txheej txheem xa mus, xws li changeAnimation (), changeSpeed () thiab changeColor () yuav raug hu ua timer2 cuam tshuam, yog li tsis txhob siv ncua () lossis lwm yam cuam tshuam-raws li kev ua haujlwm hauv nws.
Pom zoo:
Christmas Light Show Synchronized to Music !: 4 Kauj Ruam
Christmas Light Show Synchronized to Music !: Hauv cov lus qhia no, Kuv yuav qhia koj yuav ua li cas thiaj ua Christmas teeb pom kev zoo sib xws rau Christmas nkauj siv RGB RGB. Tsis txhob cia lub npe ntawd ua rau koj ntshai! Nws tsis nyuaj rau kawm paub yuav ua li cas. Kuv yuav ceeb toom koj txawm hais tias qhov no tuaj yeem ua tau zoo
Ua pa Tsob Ntoo Christmas - Arduino Christmas Lub Teeb Tswj: 4 Cov Kauj Ruam
Ua Tsis Tau Ntoo Christmas-Arduino Christmas Lub Teeb Meem: Nws tsis yog xov xwm zoo uas lub thawv tswj rau kuv 9-ft ua ntej teeb tsob ntoo Christmas tawg ua ntej Christmas , thiab cov chaw tsim khoom tsis muab hloov chaw. Qhov tsis txaus ntseeg no qhia yuav ua li cas thiaj ua rau koj tus kheej lub teeb LED tsav tsheb thiab tus tswj siv Ar
LED Circuit Board Christmas Christmas Ntoo Ornament: 15 Kauj Ruam (nrog Duab)
LED Circuit Board Christmas Christmas Ornament: Hnub Christmas no, Kuv txiav txim siab ua Christmas cov khoom siv los muab rau kuv cov phooj ywg thiab tsev neeg. Kuv tau kawm KiCad xyoo no, yog li kuv txiav txim siab ua cov khoom qub tawm ntawm cov rooj sib tham. Kuv tau ua txog 20-25 ntawm cov khoom qub no. Kev kho kom zoo nkauj yog lub voj voog
Hall Effect Sensor: Christmas Music Box: 4 Kauj Ruam
Hall Effect Sensor: Christmas Music Box: Nov yog lub npov suab paj nruag uas qhib nkauj thaum qhib (saib daim vis dis aus!). Nws yog qhov zoo, tshwj xeeb, thiab txoj hauv kev tshwj xeeb los qhwv koj cov khoom plig rau koj tus neeg tshwj xeeb! Nws siv lub cuab yeej ntsuas lub ntsej muag txhawm rau txheeb xyuas yog tias lub hau tau qhib los ntawm qhov tsis muaj qhov sib nqus
Arduino Christmas Cheer !: 5 Kauj Ruam (nrog Duab)
Arduino Christmas Cheer!: Tiss the season to stick Arduino's in festive places, and what better place than a Christmas tree! Hauv txoj haujlwm no, peb tab tom yuav ua tsob ntoo Christmas uas tuaj yeem hu nkauj ntau cov nkauj Christmas sib txawv thiab teeb ua ke nrog cov mu