Cov txheej txheem:

Arduino Nano Baised IR Tswj RGB LED: 5 Kauj Ruam
Arduino Nano Baised IR Tswj RGB LED: 5 Kauj Ruam

Video: Arduino Nano Baised IR Tswj RGB LED: 5 Kauj Ruam

Video: Arduino Nano Baised IR Tswj RGB LED: 5 Kauj Ruam
Video: How to control LEDs using IR remote | Arduino 2024, Kaum ib hlis
Anonim
Arduino Nano Baised IR Tswj RGB LED
Arduino Nano Baised IR Tswj RGB LED

hauv qhov haujlwm me no kuv xav qhia koj li cas kuv tsim Arduino raws RGB LED uas tau tswj los ntawm IR chaw taws teeb thiab siv los ntawm USB cable.

Khoom siv

1. RGB LED

2. IR tus txais

3. USB cable

4. Arduino nano

5. IR chaw taws teeb

6. qee cov xov hlau

7. 50-100 ohm resistors (kuv siv 47 ohm resistors tab sis tsis muaj qhov sib txawv ntau)

Kauj ruam 1: Xaiv Koj Cov Chaw Taws Teeb

Xaiv Koj Cov Chaw Taws Teeb
Xaiv Koj Cov Chaw Taws Teeb

Yog li qhov chaw nyob twg koj siv yog koj qhov kev txiav txim siab, tab sis koj lub chaw taws teeb yuav tsum muaj 6 tus yuam sij uas koj xav siv. 2 ntawm lawv yog rau Liab, 2 ntawm lawv rau Ntsuab thiab 2 rau Xiav.

Kauj Ruam 2: Tsim Nws ntawm Pawg Cij Ua Ntej Ua Ntej (Tsis Xav Tau Tab sis Pom Zoo)

Ua Nws ntawm Pawg Cij Ua Ntej Ua Ntej (Tsis Xav Tau Tab sis Pom Zoo)
Ua Nws ntawm Pawg Cij Ua Ntej Ua Ntej (Tsis Xav Tau Tab sis Pom Zoo)
Tsim Nws ntawm Pawg Cij Ua Ntej Ua Ntej (Tsis Xav Tau Tab sis Pom Zoo)
Tsim Nws ntawm Pawg Cij Ua Ntej Ua Ntej (Tsis Xav Tau Tab sis Pom Zoo)

Tam sim no, tsim lub Circuit Court ntawm daim ntawv qhia zaub mov

kev sib txuas:

RGB LED GND> Arduino nano GND

RGB LED Liab> Arduino nano Digital pin 5

RGB LED Ntsuab> Arduino nano Digital tus pin 6

RGB LED Xiav> Arduino nano Digital pin 9

USB GND> Arduino nano GND

USB 5v> Arduino nano 5v

IR tus pin 1> Arduino nano Digital tus pin 4

IR tus pin 2> Arduino nano GND

IR tus pin 3> Arduino nano 5v

(txhua qhov kev sib txuas tau qhia saum toj no)

(txhua tus lej xim ntawm RGB LED txuas nrog koob rau cov tiv thaiv)

Kauj Ruam 3: Txoj Cai

code yog cov hauv qab no:

Nov yog lub tsev qiv ntawv uas kuv tau siv.

#suav nrog

int IR_Recv = 4; // IR tus pin

int Rauv = 0; int Gval = 0; int IB = 0; int RvalDemo = 0; int GvalDemo = 0; int BvalDemo = 0; int R = 5; // Liab pin int G = 6; // Ntsuab tus pin int B = 9; // Tus lej xiav #define Rup1 1976685926 // ua rau lub teeb liab nce mus #define Rup2 3772818013 // ua rau lub teeb liab nce mus #define Rdown1 3843765582 // ua rau lub teeb liab poob qis #define Rdown2 3772813933 // ua rau lub teeb liab poob qis #define Gup1 3772797613 // ua rau lub teeb ci ntsuab nce mus #define Gup2 3774104872 // ua kom lub teeb ci ntsuab nce mus #define Gdown1 3772834333 // ua rau lub teeb ci ntsuab poob qis #define Gdown2 1784778242 // ua kom pom kev ntsuab ntsuab poob qis #define Bup1 3980777284 // ua rau xiav ci ntsa iab nce mus #define Bup2 3772781293 // ua rau lub teeb ci ntsa iab nce mus #define Bdown1 3772801693 // ua rau lub teeb ci ntsa iab poob qis #define Bdown2 3361986248 // ua rau lub teeb ci ci mus qis // NCO TSEG: Koj yuav tsum hloov tus lej rau koj tus kheej !!! ! // Kuv muaj 2 tus lej sib piv piv txwv Rup1 thiab Rup2. vim // kuv cov chaw taws teeb tso tawm 2 tus lej thaum koj nias ib qho. // hauv koj rooj plaub koj tuaj yeem tso tus lej tib yam hauv Rup1 thiab Rup2, Gup1 thiab Gup2 thiab ib qho. // Thaum koj nias tus yuam sij tus lej yuav tsum tshwm hauv Serial monitor, // Qhov ntawd yog yam koj yuav tsum ntaus hauv "#define" ntu. IRrecv irrecv (IR_Recv); decode_results cov txiaj ntsig; void setup () {TCCR2A = _BV (COM2A1) | _BV (COM2B1) | _BV (WGM21) | _BV (WGM20); TCCR2B = _BV (CS22); irrecv.enableIRIn (); pinMode (R, OUTPUT); pinMode (G, OUTPUT); pinMode (B, NTAWV); Serial.begin (9600); } void loop () {if (irrecv.decode (& results)) {ntev int decCode = results.value; hloov (results.value) {/////////// RED case Rup1: Rval = Rval + 10; tawg; rooj plaub Rup2: Rval = Rval + 10; tawg; case Rdown1: Rval = Rval - 10; tawg; case Rdown2: Rval = Rval - 10; tawg; //////////// GREEN case Gup1: Gval = Gval + 10; tawg; rooj plaub Gup2: Gval = Gval + 10; tawg; rooj plaub Gdown1: Gval = Gval - 10; tawg; rooj plaub Gdown2: Gval = Gval - 10; tawg; ///////////// BLUE case Bup1: Bval = Bval + 10; tawg; rooj plaub Bup2: Bval = Bval + 10; tawg; rooj Bdown1: Bval = Bval - 10; tawg; rooj Bdown2: Bval = Bval - 10; tawg; //////////////////////////////////////////} irrecv.resume (); } yog (Rval> 255) (Rval = 255); yog (Rauv 255) (Gval = 255); yog (Gval 255) (Bval = 255); yog (Bval <0) (Bval = 0); analogWrite (R, Rval); analogWrite (G, Gval); analogWrite (B, Bval); Serial.println (results.value); qeebMicroseconds (1); }

Kauj ruam 4: Ua tiav

Ua tiav
Ua tiav
Ua tiav
Ua tiav
Ua tiav
Ua tiav

Kuv tsis tau ua txoj haujlwm zoo ntawm lub casing. txhua yam kuv tau ua tsuas yog kaw nws, tab sis kuv sim ua kom nws me me li sai tau.

Yog tias koj muaj lus nug lossis ib qho yuam kev nco ntsoov qhia rau kuv, kuv yuav ua qhov zoo tshaj los pab koj kho qhov yuam kev. ua tsaug rau kev nyeem ntawv.

Pom zoo: