Cov txheej txheem:

Qhov zoo tshaj plaws RGB LEDs rau Txhua Qhov Haujlwm (WS2812, Aka NeoPixels): 6 Cov Kauj Ruam (nrog Duab)
Qhov zoo tshaj plaws RGB LEDs rau Txhua Qhov Haujlwm (WS2812, Aka NeoPixels): 6 Cov Kauj Ruam (nrog Duab)

Video: Qhov zoo tshaj plaws RGB LEDs rau Txhua Qhov Haujlwm (WS2812, Aka NeoPixels): 6 Cov Kauj Ruam (nrog Duab)

Video: Qhov zoo tshaj plaws RGB LEDs rau Txhua Qhov Haujlwm (WS2812, Aka NeoPixels): 6 Cov Kauj Ruam (nrog Duab)
Video: Xov tooj & Computer Accessories Tuam Tshoj Hoobkas, pob ntseg wireless, txawb lus nrog lub charger 2024, Hlis ntuj nqeg
Anonim
Qhov zoo tshaj plaws RGB LEDs rau Txhua Qhov Haujlwm (WS2812, Aka NeoPixels)
Qhov zoo tshaj plaws RGB LEDs rau Txhua Qhov Haujlwm (WS2812, Aka NeoPixels)
Qhov zoo tshaj plaws RGB LEDs rau Txhua Qhov Haujlwm (WS2812, Aka NeoPixels)
Qhov zoo tshaj plaws RGB LEDs rau Txhua Qhov Haujlwm (WS2812, Aka NeoPixels)
Qhov zoo tshaj plaws RGB LEDs rau Txhua Qhov Haujlwm (WS2812, Aka NeoPixels)
Qhov zoo tshaj plaws RGB LEDs rau Txhua Qhov Haujlwm (WS2812, Aka NeoPixels)

Thaum peb ua haujlwm nrog LEDs, peb feem ntau nyiam tswj hwm lawv lub xeev (qhib/tawm), ci ntsa iab, thiab xim. Muaj ntau yam, ntau txoj hauv kev los mus txog qhov no, tab sis tsis muaj ib qho kev cog lus me me li WS2812 RGB LED. Hauv nws qhov me me 5mm x 5mm pob, WS2812 suav nrog 3 lub ntsej muag ci ci zoo nkauj (Liab, Ntsuab, thiab Xiav) thiab cov kab hluav taws xob sib zog (WS2811) uas tsuas yog xav tau ib cov ntaub ntawv nkag los tswj lub xeev, ci ntsa iab, thiab xim ntawm 3 LEDs. Thaum tus nqi xav tau tsuas yog ib kab ntawv cov ntaub ntawv los tswj 3 LEDs, muaj qhov xav tau rau lub sijhawm kom raug hauv kev sib txuas lus nrog WS2811. Vim li no, yuav tsum muaj lub microcontroller lub sijhawm tiag tiag (piv txwv li, AVR, Arduino, PIC). Hmoov tsis zoo, Linux-based microcomputer lossis txhais lub microcontroller xws li Netduino lossis Basic Stamp tsis tuaj yeem muab sijhawm txaus kom raug raws li qhov xav tau. Thiab yog li, hauv Phau Ntawv Qhia no kuv taug kev los ntawm cov txheej txheem teeb tsa, thiab tswj ib qho ntawm cov LEDs no nrog Arduino Uno. Tom qab ntawd, kuv qhia qhov yooj yim npaum li cas los txuas ob peb ntawm lawv ua ke rau qhov teeb pom kev zoo txaus!

Kauj Ruam 1: Cov Npe Khoom

Cov Khoom Siv
Cov Khoom Siv

Qhov zoo nkauj RGB LED los hauv 5050 (5mm x 5mm) pob nrog 6 pawm uas yooj yim haum rau cov laug rau ntawm lub rooj sib cais. Raws li tsuas yog qhov xav tau ntxiv yog de-coupling capacitor, WS2812 ncaj ncees muab cov tshuaj zoo tshaj plaws rau kev tswj xim thiab ci ntawm RGB LED. Tus neeg tsav tsheb coj mus tas li tam sim no LED (WS2811) yog qhov muaj txiaj ntsig zoo rau ob qho laj thawj: - Qhov tsis tu ncua tam sim no ntawm ~ 18mA yuav tsav txhua lub LED txawm tias qhov hluav taws xob sib txawv. - Tsis tas yuav tsum tau ntxiv cov kev txwv tam sim no (aka choke resistors) nruab nrab ntawm cov khoom siv hluav taws xob thiab cov LEDs. Txhua yam peb xav tau yog tus qauv siv yooj yim heev los muab Lub Hwj Chim, Hauv Paus, thiab 1 Tswj Kev Nkag Mus txhawm rau txhawm rau tsim kom pom cov teeb pom kev zoo uas tsis suav nrog ib qho, tab sis tag nrho cov kab ntawm RGB LEDs. Yog lawm! Los ntawm kev txuas Cov Ntaub Ntawv Tawm tus pin ntawm ib qho ntawm cov LEDs no, rau Cov Ntaub Ntawv Hauv tus pin ntawm lwm tus, peb tuaj yeem tsav lawv ob leeg ntawm nws tus kheej nrog tib lub tswv yim tswj! Yog tias nws tsis pom tseeb yuav ua li cas, tsis txhob nyuaj siab, los ntawm qhov kawg ntawm Cov Lus Qhia no koj yuav zoo ntawm koj txoj hauv kev ntxiv WS2812 rau txhua qhov haujlwm koj xav tau! Txog qhov Qhia Qhia ntawm no yog qhov peb yuav siv: Cov ntaub ntawv: 3 x WS2812 RGB LEDs (ua ntej muag mus rau lub rooj sib txig me me) 1 x Tsis Siv Tshuaj Txhuam Txhuam Txhuam Txhuam Khoom Hlau (ntau xim; 28 AWG) 1 x Arduino Uno R3 1 x Break-away Pin Connector, 0.1 "Suab, 8-Pin Male (Txoj Cai-Lub) 1 x Pin Connector, 0.1" Suab, 8-Pin Poj Niam (Txoj Cai-Lub) 1 x Breakaway Pin Connector, 0.1 "Suab, 8-Pin MaleTools: PC USB A/B Cable Wire Stripper Soldering IronNotes: Nyob ntawm koj qhov haujlwm, WS2812 RGB LEDs kuj tseem muaj yam tsis muaj pawg thawj coj tawg rau txog $ 0.40 txhua, tab sis qhov yooj yim ntawm kev xaiv ua ntej muag yog txaus nyiam rau cov ntawv thov yooj yim.

Kauj Ruam 2: Txuas Tus Pin Headers

Txuas tus Pin Headers
Txuas tus Pin Headers
Txuas tus Pin Headers
Txuas tus Pin Headers
Txuas tus Pin Headers
Txuas tus Pin Headers

Nrog txhua cov ntaub ntawv teev tseg hauv cov kauj ruam dhau los, nws yog qhov ncaj ncaj rau pem hauv ntej kom pom lub teeb WS2812 RGB LED. Ua ntej, peb xav npaj WS2812 Breakout Boards rau muab lawv tso rau ntawm lub khob cij uas tsis muaj kab. Txhawm rau ua qhov no, peb siv lub tshuab txiav hlau (feem ntau cov cuab yeej txiav yuav ua haujlwm ib yam nkaus) cais txhua 8-Pin sawb rau hauv 2 x 3-Pin daim. Nco ntsoov tias kev txiav yog qhov nyuaj me ntsis; ntau zaus kuv tau sim siv qhov zawj ntawm ob tus txiv neej lub taub hau raws li phau ntawv qhia rau kev txiav, thiab kuv tau xaus txiav cov yas ntau dhau ntawm lub taub hau uas kuv xav khaws. Los ntawm 'txi' tus pin uas peb xav txiav, peb zam qhov teeb meem tag nrho. Siv ob rab phom, peb rub tus pin qhov peb xav txiav (qhov no, tus lej 4 thiab 8). Tom qab cov pins tau raug tshem tawm peb tuaj yeem yooj yim txiav nruab nrab ntawm cov npe tam sim no-khoob. Cov txheej txheem no ua haujlwm zoo ib yam nrog tus poj niam lub taub hau. Tom qab txiav thiab txiav, peb yuav tsum muaj 6 x 3-Pin headers, uas yog, 2 x tus qauv thiab 4 x txoj cai kaum (2 x txiv neej, 2 x poj niam). Nrog kev pab los ntawm cov hlau txuas, tam sim no peb tuaj yeem txuas cov pins rau txhua ntawm peb lub rooj sib cais hauv qab no. Ib lub rooj tsavxwm yuav tsum muaj 2 x tus qauv lub taub hau, hos lwm ob lub rooj tsavxwm yuav tsum txhua tus muaj 1 x lub kaum sab xis. Ntawm lub rooj tsavxwm uas yuav muaj tus lej tus lej tus lej, peb tso cov pins rau hauv qab ntawm lub rooj tsavxwm (sab rov qab rau qhov LED yog). Ntawm ob qhov ntxiv, lub kaum sab xis sab xis (ib ntawm txhua tus poj niam txiv neej) tuaj yeem tso rau saum toj lossis hauv qab. Nco ntsoov tias nws yog ib qho tseem ceeb kom ua tau zoo ib yam, los ntawm ib lub rooj tsavxwm mus rau lwm qhov, ntawm qhov chaw ntawm txiv neej thiab poj niam lub taub hau. Nws yog qhov muaj txiaj ntsig zoo los siv cov nplai mount capacitor rau kev taw qhia cov laug cam; siv qhov no los siv, tus txiv neej lub taub hau yuav tsum tau muab txuas rau qhov kawg ze rau lub capacitor. Thaum cov pins raug muag, peb tau npaj los txuas ib qho ntawm lawv mus rau Arduino!

Kauj Ruam 3: Txuas WS2812 Breakout Board rau Arduino

Txuas WS2812 Breakout Board rau Arduino
Txuas WS2812 Breakout Board rau Arduino
Txuas WS2812 Breakout Board rau Arduino
Txuas WS2812 Breakout Board rau Arduino
Txuas WS2812 Breakout Board rau Arduino
Txuas WS2812 Breakout Board rau Arduino

Hauv cov kauj ruam no peb yuav tsim kev sib txuas tsim nyog ntawm Arduino, thiab ib qho ntawm peb WS2812 Breakout Boards. Rau lub hom phiaj no peb yuav siv cov laug cam uas tsis txhuam, thiab 3 x txuas xov hlau. Yog tias koj tab tom siv txoj hlua hlau, tam sim no yog lub sijhawm txiav 3 daim, txhua qhov ntev txog 4 . Tam sim no peb tuaj yeem tso WS2812 Breakout Board (ib qho nrog cov qauv txheem taub hau) hla qhov faib ntawm peb lub khob cij. tias Arduino raug txuas los ntawm ob lub zog thiab USB, peb yuav txuas mus txuas xov txuas rau ntawm sab qab ntawm WS2812 Breakout Board peb tuaj yeem pom lub npe ntawm txhua tus pin: VCC, DI (DO), GND. qhov no yog phau ntawv qhia peb txuas mus txuas 5V thiab GND pins los ntawm Arduino mus rau VCC thiab GND pins ntawm WS2812 pawg thawj coj saib, feem., uas yog tus pin nruab nrab ntawm sab uas ze tshaj plaws rau lub capacitor.

Kauj Ruam 4: Ua Nws Tsaug Nrog Arduino IDE

Ua Nws Tsaug Nrog Arduino IDE
Ua Nws Tsaug Nrog Arduino IDE
Ua Nws Tsaug Nrog Arduino IDE
Ua Nws Tsaug Nrog Arduino IDE

Kuv yuav xav tias koj twb tau teeb tsa Arduino IDE rau koj lub khoos phis tawj --- ntau cov lus qhia hauv lub vev xaib piav qhia tus txheej txheem zoo heev. Txoj haujlwm peb yuav xav tau thauj mus rau peb Arduino tuaj yeem rub tawm ntawm no. Tom qab peb tuaj yeem yooj yim ob zaug -cov ntaub ntawv primer.ino hauv lub firmware> piv txwv> primer nplaub tshev kom thauj nws mus rau Arduino IDE (wirtten rau version 1.0.5). Cov pob suav nrog cov tsev qiv ntawv tsim nyog rau cov cai los ua ke yog li yuav tsum tsis muaj qhov yuam kev, thov tshaj tawm cov lus qhia yog tias koj ntsib teeb meem ua ke. Tom qab xaiv hom Arduino pawg thawj coj saib, thiab USB chaw nres nkoj siv cov cuab yeej ntawv qhia zaub mov xaiv, upload cov cai, thiab WS2812 yuav tsum pib ntsais muag hloov ntawm Liab, Ntsuab, thiab Xiav. Qhov ua tau zoo tshaj plaws txog cov WS2812 RGB LEDs yog tias lawv tuaj yeem 'daisy-saw' ncaj ncees yooj yim los tsim cov kab ntev thiab cov kab uas muaj ntau ntawm cov LEDs no. Hauv cov kauj ruam tom ntej peb ua qhov no meej nrog 3 cov laug cam peb tau npaj.

Kauj Ruam 5: Ua Sawb ntawm RGB LEDs

Ua Sawb ntawm RGB LEDs
Ua Sawb ntawm RGB LEDs
Ua Sawb ntawm RGB LEDs
Ua Sawb ntawm RGB LEDs

Kev teeb tsa tus tsav tsheb LED teeb tsa (WS2811) tso cai rau 'daisy-txuas' ib qho LED mus rau tom ntej siv tsuas yog 1 kab ntawv (!). Los ntawm kev txuas Cov Ntaub Ntawv Tso Tawm ntawm ib qho WS2812 rau hauv Cov Ntaub Ntawv Tawm ntawm lwm qhov, peb tuaj yeem tswj qhov ci thiab xim ntawm tag nrho cov kab ntawm LEDs txog 500 ntawm lawv ntawm Arduino! Tau kawg, txhawm rau tsav ntau lub LEDs qee qhov kev txiav txim siab tau ua: - Txhua lub pixel rub mus txog 60mA (dawb ntawm qhov ci tag nrho xav tau txhua lub LEDs kom nyob, txhua daim duab ~ 20mA). - Ib qho Arduino yuav tshaj tawm nws RAM tsav 500 LEDs ntawm qhov hloov tshiab ntawm 30 Hz. - Txhawm rau txuas ob lub rooj sib tham ua ke, qhov pom zoo tshaj plaws sib cais yog 6 "kom tsis txhob poob lub hwj chim, thiab cov ntaub ntawv tsis ncaj ncees. thiab muaj zog heev rau kev hloov pauv ntawm (me me) roj teeb hloov pauv mus rau. Tom qab ntawd, nrog peb Arduino board txiav tawm los ntawm Lub Hwj Chim thiab USB, peb tso tus txiv neej kawg los ntawm ob-lub rooj sib tham saw ntawm lub khob cij uas tsis muaj kab xev. twb tau lawm. Qhov kev sib koom ua ke no yuav muaj VCC thiab GND pins los ntawm ob qho tib si lub taub hau ncaj ncaj thiab cov saw hlau nyob rau tib kab ntawm lub khob cij.. Ua fter txhua yam txuas nrog, peb tuaj yeem tua Arduino IDE thiab siv Text Editor los hloov lub ntsiab lus "#define NUM_LEDS 1" rau "#define NUM_LEDS 3". Tom qab txuas lub rooj tsav xwm rov qab rau Lub Hwj Chim thiab/lossis USB, peb tuaj yeem tso qhov haujlwm tshiab… thiab… BAM! Tag nrho peb lub LEDs yuav tsum ntsais ib yam nkaus!

Kauj Ruam 6: Mus Rau Qhov Tsaus Ntuj, Cia Kom Pom Kev

Mus Rau Qhov Tsaus Ntuj, Cia Li Pom Kev!
Mus Rau Qhov Tsaus Ntuj, Cia Li Pom Kev!
Mus Rau Qhov Tsaus Ntuj, Cia Li Pom Kev!
Mus Rau Qhov Tsaus Ntuj, Cia Li Pom Kev!

Cov lus qhia no tau qhia sai sai rau koj yuav siv WS2812 RGB LED ua ntej muag mus rau cov laug cam tawg yooj yim. Peb siv Arduino los tswj qhov ci thiab xim ntawm LEDs. Ib yam uas ua rau poob siab me ntsis yog qhov chaws uas peb tau siv ua rau LEDs ntsais tag nrho ib zaug, nrog rau qhov sib zog thiab xim zoo ib yam. Hom kev ua haujlwm no tsis nthuav tawm lub peev xwm ntawm 'ntse' LED tsav tsheb (WS2811) uas tau muab tso rau hauv pob no. Thiab yog li, cia peb sim cov kev hloov kho hauv qab no rau tus lej qub. Raws li ua ntej, koj yuav rub tawm thiab unzip cov ntaub ntawv, thiab tom qab ntawd qhib lub firmware kom raug thauj mus rau Arduino (firmware> teebmeem> effects.ino). Txhua cov ntaub ntawv xav tau rau qhov kev ua yeeb yaj kiab no tau suav nrog yog li tsis tas yuav ntxiv cov neeg thib peb kev ywj pheej; cov cai yuav tsum suav ua yam tsis muaj kev hloov pauv --- nws twb tau teeb tsa los daws qhov 3 LEDs. Tam sim no nws yog nyob ntawm koj lub tswv yim los tsim txoj haujlwm tom ntej uas cov no muaj txiaj ntsig zoo, kev cog lus, RGB LEDs yuav ci lawv lub teeb. Xav tias dawb tshaj tawm qee qhov ntawm koj tus kheej kev tsim uas siv WS2812 hauv cov lus pom!

Pom zoo: