RGB LED yog peb lub LED ntawm cov xim sib txawv (Liab - liab, Ntsuab - ntsuab, Xiav - xiav), tau ntim rau hauv ib lub tsev. Cia peb pom yuav txuas RGB LED rau Arduino li cas.
Nws yog qhov tsim nyog
- - Arduino;
- - RGB LED;
- - 3 resistors rau 220 Ohm;
- - txuas cov xaim;
- - khob cij board;
- - khoos phis tawj.
Cov Lus Qhia
Kauj ruam 1
RGB LED yog ntawm ob hom: nrog cov anode sib xws ("ntxiv rau") thiab ib qho cathode ("rho tawm"). Daim duab qhia tau hais tias tus qauv kos duab ntawm ob hom LEDs no. Ceg ceg ntev ntawm LED yog tas txhua lub hwj huam txhuas. Cov xim coj liab LED (R) yog nyob rau nyias, ntsuab (G) thiab xiav (B) yog nyob rau lwm qhov ntawm anode, zoo li pom hauv daim duab. Hauv tsab xov xwm no, peb yuav saib txoj kev sib txuas ntawm RGB LED nrog ob qho tib si ib qho ntawm qhov ntsuas thiab ib qho cathode.
Kauj ruam 2
Daim duab sib txuas xov tooj cua txuas rau RGB LED nrog ib qho kev sib koom ua ke yog qhia hauv daim duab. Peb txuas qhov anode rau "+5 V" ntawm pawg thawj coj saib Arduino, lwm peb pins txuas rau arbitrary digital pins.
Thov nco ntsoov tias peb tab tom txuas txhua tus ntawm LED los ntawm nws cov resistor, thiab tsis siv ib qho sib xws. Nws raug nquahu kom ua li ntawd, vim tias txhua tus ntawm LED tau nws tus kheej qhov siv tau. Thiab yog tias koj txuas rau lawv tag nrho los ntawm ib qho ຕ້ານ, cov LED yuav ci nrog qhov sib txawv.
Kauj ruam 3
Cia peb rov sau zaj dab neeg classic "ntsais". Peb yuav qhib kom zoo thiab yuav luag txhua qhov peb xim tig. Nco ntsoov tias cov LED yuav taws thaum peb thov LOW rau lub xov tooj ntawm Arduino coj.
Kauj ruam 4
Cia peb pom lub teeb nyem RGB LEDs hauv kev nqis tes ua. Lub LED tig rau hauv lem liab, ntsuab thiab xiav. Txhua lub teeb tsa ua lub teeb rau 1 vib nas this, tom qab ntawd tawm mus ntev li 2 vib nas this, thiab tom qab ntawv tig mus.
Koj tuaj yeem ua lub teeb ci rau txhua tus channel sib cais, koj tuaj yeem ua rau tib lub sijhawm, tom qab ntawd cov xim ci ci yuav hloov.
Kauj ruam 5
Yog tias koj siv hom cathode RGB LED, tom qab ntawd txuas cov hlau ntev ntawm LED mus rau GND ntawm Arduino board thiab R, G thiab B channel rau digital ports ntawm Arduino. Nws yuav tsum nco ntsoov tias cov LEDs teeb ci ntsa iab thaum qib siab (HIGH) tau thov rau cov channel R, G, B, hauv kev sib piv rau cov LED nrog qhov sib cuam tshuam.
Yog tias koj tsis hloov cov duab kos sab saud, tom qab ntawd txhua lub xim ntawm LED hauv qhov no yuav nyob ntev li 2 vib nas this, thiab txoj kev ncua ntawm lawv yuav yog 1 thib ob.