Cov txheej txheem:

Bluetooth Tswj NeoPixel Christmas Tree: 5 Kauj Ruam
Bluetooth Tswj NeoPixel Christmas Tree: 5 Kauj Ruam

Video: Bluetooth Tswj NeoPixel Christmas Tree: 5 Kauj Ruam

Video: Bluetooth Tswj NeoPixel Christmas Tree: 5 Kauj Ruam
Video: 6 Types Of Lightsabers! 2024, Kaum ib hlis
Anonim

Koj puas tau xav paub yuav ua li cas ntxiv IoT (Internet ntawm Yam) hauv koj tsob ntoo Christmas xyoo no? Zoo, nws yog qhov ua tau! Kuv tus kheej hu txoj haujlwm no "ArduXmas", thiab nws muaj RGB NeoPixel coj sawb tswj los ntawm Arduino board ntawm Bluetooth. Nov yog qhov pib ua haujlwm zoo thiab qhia zoo rau Arduino e IoT, yog li tau txais koj cov cuab yeej thiab cia peb ua nws!

Khoom siv:

Rau qhov haujlwm no koj yuav xav tau:

  • Arduino (Kuv siv Nano, tab sis ib qho twg yuav ua haujlwm, tsuas yog nco ntsoov ua kom raug lub zog ntawm koj lub rooj tsavxwm)
  • NeoPixel WS2812b LED sawb
  • HC-06 Bluetooth module
  • 5V 2A DC fais fab mov
  • DC Barrel Power Jack/Txuas
  • Phenolite phaj rau tuav cov khoom
  • Cov ntaub ntawv kaw
  • Android smartphone nrog Blynk app teeb tsa

Kauj ruam 1: Circuit Court

Qhov Circuit
Qhov Circuit
Qhov Circuit
Qhov Circuit
Qhov Circuit
Qhov Circuit

Cov khoom siv hluav taws xob ntawm txoj haujlwm no yooj yim heev. Arduino, Bluetooth module thiab LED sawb tau siv los ntawm 5V cov khoom (xyuas kom txhua GNDs txuas nrog ua ke). Arduino pawg thawj coj tau siv los ntawm 5V chaw nres nkoj (NCO NTSOOV: Ua kom lub zog Arduino siv 5V chaw nres nkoj tuaj yeem ua rau koj lub rooj tsav xwm puas tsuaj yog tias koj tsis ceev faj. thiab GND xov hlau). Qhov tam sim no muab los ntawm koj lub zog siv yuav nyob ntawm qhov ntev ntawm koj cov hlua LED. Kuv siv 180 leds nrog 40% ntawm qhov ci tag nrho thiab 2 amps tuav tau zoo, tab sis nco ntsoov nco ntsoov muab cov khoom tsim nyog tam sim no (Nco ntsoov: Txhua RGB LED siv ib puag ncig 20mA + 20mA + 20mA = 60mA).

HC-06 Bluetooth module txuas nrog tus pin 0 thiab 1 (RX, TX) ntawm Arduino, tsuas yog nco ntsoov tias siv tus qauv no, HC-06's RX tus pin txuas nrog Arduino's TX thiab HC-06's TX tus pin yog txuas nrog Arduino's RX. Cov no yog cov txuas txuas txuas ntawm lub rooj tsavxwm, thiab tau siv txhawm rau kom tau txais cov lus txib los ntawm lub xov tooj ntawm tes. Kuv ntxiv qhov hloov pauv kom yooj yim qhib lub module rau/tawm yog li kuv tuaj yeem tua nws thaum ua haujlwm ntawm lub rooj tsavxwm, txwv tsis pub lub khoos phis tawj tsis tuaj yeem sib txuas lus nrog Arduino.

Hauv Circuit Court cov ntaub ntawv tawm tus pin mus rau LED sawb yog tus lej digital 2, tab sis koj tuaj yeem xaiv ib qho PWM tus pin thiab hloov nws raws txoj cai (NCO NTSOOV: NeoPixel's LED strips muaj cov lus qhia rau cov ntaub ntawv teeb liab. xub cim hauv koj kab txaij).

Txhawm rau ua kom muaj kev sib txuas Kuv tab tom siv phaj phenolite nrog qhov nyob hauv nws yog li nws yooj yim rau cov kab laug sab thiab coj nws sib nrug xyoo tom ntej.

Kauj Ruam 2: Cov ntaub ntawv kaw

Cov ntaub ntawv kaw
Cov ntaub ntawv kaw
Cov ntaub ntawv kaw
Cov ntaub ntawv kaw
Cov ntaub ntawv kaw
Cov ntaub ntawv kaw

Rau lub thawv ntawv Kuv tsuas yog siv phau qub phau ntawv lub hwj chim muab cov khoom uas haum zoo rau cov khoom. Ruaj ntseg txhua yam nrog cov kua nplaum kub, thiab tawm qhov rau Arduino USB chaw nres nkoj, HC-06's hloov, DC txuas thiab LED txuas txuas.

Kauj ruam 3: Blynk App

App ntawm Blynk
App ntawm Blynk
App ntawm Blynk
App ntawm Blynk
App ntawm Blynk
App ntawm Blynk

Txog kev sib txuas lus nrog Arduino peb tab tom siv Blynk app. Nrog Blynk koj tuaj yeem yooj yim tsim kev cuam tshuam xa cov ntaub ntawv los ntawm lub xov tooj smartphone mus rau kho vajtse lossis lwm txoj hauv kev, nws kuj tseem tuaj yeem tswj ncaj qha lub microcontroller cov chaw nres nkoj yam tsis hloov ib kab ntawm cov cai!

DISCLAIMER: Hmoov tsis daim ntawv thov no tsuas yog ua haujlwm rau Android smarphones vim tias Bluetooth feature tseem nyob hauv Beta thiab tsis muaj rau IOS tseem, qhov no tseem txhais tau tias nws yuav tsis tuaj yeem xa tawm qhov haujlwm raws li ib leeg ib leeg app.

Teem koj lub app kom tau txais daim ntawv pov thawj kev lees paub rau koj txoj haujlwm hauv koj li email (qhov kev lees paub no yuav xav tau tom qab ntawm Arduino tus lej). Blynk lub vev xaib muaj kev qhia ib qib zuj zus zoo txog qhov no, txheeb xyuas nws:

Rau qhov haujlwm no kuv tab tom siv ob lub nyees khawm rau kev hloov pauv ntawm 2 ua ntej-coded teeb pom kev zoo; ib qho RGB tivthaiv los teeb cov hlua LED xim; ib tus swb kom tswj tau qhov ci ci thiab ib qho khoom siv bluetooth los txuas rau Arduino. Txheeb cov duab kom pom tias txhua qhov khoom siv tau teeb tsa li cas. Ua tib zoo saib cov pins siv rau txoj haujlwm no zoo li peb tab tom siv Blynk's Virtual Pins, qhov no yog qhov zoo uas tso cai rau xa cov ntaub ntawv los ntawm app mus rau kho vajtse. Yog xav paub ntxiv txog Virtual Pins:

Kauj ruam 4: Arduino Code

Arduino Txoj Cai
Arduino Txoj Cai

Nws yog lub sijhawm kom tau txais qee qhov chaws ua tiav! Cov ntaub ntawv kuv muab muaj cov qauv yooj yim los ua haujlwm, tab sis koj tuaj yeem hloov nws raws li koj xav tau. Txhawm rau kom nws ua haujlwm tau zoo txawm li cas los xij, koj yuav tsum hloov daim ntawv pov thawj char nrog cov cim koj tau txais hauv koj li email. Tsis tas li nco ntsoov hloov LED_PIN thiab LED_COUNT qhov sib txawv raws li koj teeb tsa.

Tus cwj pwm ntawm LEDs tau hais los ntawm cov tsiaj ntawv sib txawv uas hloov pauv thaum thov tau txais los ntawm app. Koj tuaj yeem ntxiv ntau qhov muaj peev xwm rau cov duab ua haujlwm raws li koj xav tau, tsuas yog ntxiv koj lub luag haujlwm rau tus qauv hloov pauv hauv toggleAnimation () muaj nuj nqi thiab muab qhov sib thooj Virtual Pin nyeem rau saum cov cai.

Cov tsiaj ntawv ua haujlwm hauv lub voj () yog khi rau lub sijhawm ua haujlwm hauv 100ms sib nrug. Qhov no yog qhov tsim nyog, thiab kuv tsis pom zoo hloov nws, vim nws cuam tshuam nrog Blynk.run () hais kom ua thiab kev sib txuas raug kaw yog tias Blynk lub tsev qiv ntawv tshawb pom ntau qhov kev thov hauv lub sijhawm luv.

Pom zoo: