Cov txheej txheem:

Siv Infrared Sensor Nrog Arduino: 8 Kauj Ruam (nrog Duab)
Siv Infrared Sensor Nrog Arduino: 8 Kauj Ruam (nrog Duab)

Video: Siv Infrared Sensor Nrog Arduino: 8 Kauj Ruam (nrog Duab)

Video: Siv Infrared Sensor Nrog Arduino: 8 Kauj Ruam (nrog Duab)
Video: Casio G-Shock Mudmaster vs Gulfmaster | G Shock GWG-1000 Mudmaster vs G Shock GWN-1000 Gulfmaster 2024, Hlis ntuj nqeg
Anonim
Siv Infrared Sensor Nrog Arduino
Siv Infrared Sensor Nrog Arduino

Dab tsi yog infrared (aka IR) sensor?

Ib qho IR sensor yog cov cuab yeej siv hluav taws xob uas ntsuas IR cov cim hauv qhov ntau zaus tshwj xeeb tau teev tseg los ntawm cov qauv thiab hloov lawv mus rau hluav taws xob teeb liab ntawm nws tus pin tso tawm (feem ntau hu ua tus pin teeb liab). Cov cim IR feem ntau yog siv rau kev xa cov lus txib saum huab cua ntawm qhov nrug deb (feem ntau ob peb metres) zoo li qhov koj twb tau ua haujlwm nrog hauv TV tswj chaw taws teeb lossis lwm yam khoom siv hluav taws xob zoo sib xws.

IR kev sib txuas lus raws tu qauv

Txhua lub teeb liab sawv cev rau tus lej tshwj xeeb. Cov cim hluav taws xob tuaj yeem hloov pauv rov qab mus rau cov ntaub ntawv/tus lej tseeb uas tus neeg xa tau xa tuaj. Thaum koj nias lub pob ntawm koj lub TV tswj chaw taws teeb, nws tsim lub teeb liab sib xws rau tus lej khawm (piv txwv li On/Off, Volume Up, thiab lwm yam) thiab xa nws rau tus txais (qhov no yog koj lub TV). Ob tus xa thiab tus tau txais kev pom zoo ntawm txheej txheej txheej kom tus txais tau paub paub yuav ua dab tsi raws li txhua tus lej. Txoj hauv kev yuav tsum tau hloov kho (ua qauv) raws li lub teeb liab tau hais tseg hauv tus qauv sib txawv thiab txhua lub chaw tsim khoom lag luam ib txwm sim tsim cov khoom lag luam sib xws nrog lawv kom nws tuaj yeem siv tau hauv cov khoom sib txawv. Ib qho ntawm cov txheej txheem paub zoo tshaj plaws yog los ntawm NEC. Koj tuaj yeem pom keeb kwm luv ntawm IR cov txheej txheem ntawm Wikipedia hauv qab Consumer IR lub npe.

Kauj Ruam 1: Tus IR Sensor Zoo Li Cas?

IR Sensor Zoo Li Cas?
IR Sensor Zoo Li Cas?
IR Sensor Zoo Li Cas?
IR Sensor Zoo Li Cas?
IR Sensor Zoo Li Cas?
IR Sensor Zoo Li Cas?

IR sensors muaj nyob ntawm ntau pob. Ntawm no koj tuaj yeem pom qee qhov ntim ntim rau tus neeg txais IR.

Kauj Ruam 2: IR Sensor Breakout Board/module

IR Sensor Breakout Board/module
IR Sensor Breakout Board/module
IR Sensor Breakout Board/module
IR Sensor Breakout Board/module
IR Sensor Breakout Board/module
IR Sensor Breakout Board/module
IR Sensor Breakout Board/module
IR Sensor Breakout Board/module

Koj tseem tuaj yeem yuav lawv ua IR module/breakout board ntawm eBay, Aliexpress lossis Amazon. Cov qauv no ib txwm suav nrog ib qho ntawm cov ntsuas tau hais los saum no nrog lub pob khoom zoo phooj ywg ua ke nrog LED uas yuav nyem thaum lub ntsuas pom lub teeb liab. Los ntawm kev ua li ntawd koj yuav pom yog tias cov ntaub ntawv raug xa mus. Kuv pom zoo kom pib nrog ib qho ntawm cov qauv no.

Nco tseg: yog tias koj muaj lub nyoos IR sensor, tsis muaj dab tsi yuav hloov pauv, tshwj tsis yog tias koj yuav tsum txheeb xyuas cov ntaub ntawv ntawm lub ntsuas kom paub tseeb tias koj tab tom txuas nws kom raug vim tias txwv tsis pub koj yuav muaj cov pa luam yeeb xiav zoo nkauj nrog tsw ntxhiab uas yuav nyob ntev teev. Koj paub kuv txhais li cas;)

Kauj Ruam 3: Yuav Tsum Xeem thiab Cheeb Tsam

Yam Yuav Tsum Tau Ua thiab Cheeb Tsam
Yam Yuav Tsum Tau Ua thiab Cheeb Tsam

Ntawm no koj tuaj yeem pom cov npe ntawm cov khoom uas koj xav tau kom ua tiav cov lus qhia no:

eBay txuas:

  • 1 x Arduino Uno:
  • 1 x IR sensor module nrog chaw taws teeb:
  • 4 x 220 ohm resistors:
  • 4 x LED:
  • 8 x Dupont cable:
  • 1 x Solderless breadboard:
  • 1 x Mini breadboard (xaiv tau):

Amazon.com txuas:

  • 1 x Arduino Uno:
  • 1 x IR sensor module nrog chaw taws teeb:
  • 1 x Solderless breadboard:
  • 4 x 220 ohm resistors:
  • 4 x LED:
  • 8 x Dupont cable:
  • 1 x Mini breadboard (xaiv tau):

Kauj Ruam 4: Txuas IR Sensor rau Arduino

Txuas IR Sensor mus rau Arduino
Txuas IR Sensor mus rau Arduino
Txuas IR Sensor mus rau Arduino
Txuas IR Sensor mus rau Arduino
Txuas IR Sensor mus rau Arduino
Txuas IR Sensor mus rau Arduino

Teeb tsa IR sensor txuas rau Arduino yog qhov yooj yim heev. Ib sab ntawm VCC thiab GND tus pin, lub ntsuas hluav taws xob tsuas muaj ib tus pin tso zis uas yuav tsum txuas nrog rau ib qho ntawm tus pin digital ntawm Arduino. Hauv qhov no nws txuas nrog tus pin 13.

Kuv sim ua kom pom ob qho tib si IR sensor module thiab nyoos IR sensor teeb tsa. Raws li tuaj yeem pom ntawm cov duab, txoj haujlwm ntawm VCC thiab GND pins ntawm lub ntsuas qhov ntsuas yog qhov sib txawv ntawm cov khoom nyoos. Txawm li cas los xij nws yuav tsis yog qhov xwm txheej rau koj lub sensor, yog li tau hais hauv cov kauj ruam dhau los, yog tias siv lub ntsuas cua nyoos, kos daim ntawv ua ntej.

Kauj Ruam 5: Nrhiav Txoj Cai Sib Raug Zoo rau Txhua Qhov Tseem Ceeb ntawm Cov Chaw Taws Teeb

Nrhiav Txoj Cai Sib Raug Zoo rau Txhua Qhov Tseem Ceeb ntawm Cov Chaw Taws Teeb
Nrhiav Txoj Cai Sib Raug Zoo rau Txhua Qhov Tseem Ceeb ntawm Cov Chaw Taws Teeb
Nrhiav Txoj Cai Sib Raug Zoo rau Txhua Qhov Tseem Ceeb ntawm Cov Chaw Taws Teeb
Nrhiav Txoj Cai Sib Raug Zoo rau Txhua Qhov Tseem Ceeb ntawm Cov Chaw Taws Teeb
Nrhiav Txoj Cai Sib Raug Zoo rau Txhua Qhov Tseem Ceeb ntawm Cov Chaw Taws Teeb
Nrhiav Txoj Cai Sib Raug Zoo rau Txhua Qhov Tseem Ceeb ntawm Cov Chaw Taws Teeb

Txhawm rau ua haujlwm rau Arduino ua qee yam thaum koj nias tus yuam sij ntawm cov chaw taws teeb, koj yuav tsum xub muaj tus lej sib xws rau tus yuam sij ntawd. Tus lej tseem ceeb yog tus lej ib txwm nthuav tawm raws li hexadecimal. Txhua lub chaw tswj chaw taws teeb muaj nws tus kheej cov txheej txheem tseem ceeb thaum nws muaj peev xwm tias ob tus tswj hwm sib koom tib txoj cai rau lub hom phiaj sib txawv. Muaj cov lej sib txawv sib txawv nrog rau kev siv ntau zaus sib txawv, ua kom ntseeg tau tias ob lub chaw taws teeb tswj ntawm cov cuab yeej sib txawv yuav tsis muaj kev cuam tshuam. Tias yog vim li cas thaum koj hloov koj lub TV channel, koj lub DVD player tsis ua haujlwm hlo li.

Txhawm rau txheeb xyuas cov lej rau koj lub chaw taws teeb IR, koj yuav tsum xub ua lub ntsej muag yooj yim uas sim nyeem cov cai los ntawm lub ntsuas pa thaum koj nias tus yuam sij thiab xa qhov ntawd ntawm qhov chaw nres nkoj txuas mus rau koj lub khoos phis tawj uas koj tuaj yeem nkag mus tau nws siv Serial Monitor cov cuab yeej ntawm Arduino IDE Cov. Nov yog qhov kos duab txuas rau ntu no ua. Nws yuav zoo dua los nyem txhua lub pob kom pom tus lej thiab sau cov npe ntawm cov lej nyob qhov twg yog li koj yuav tsis xav tau sau cov cai no ntxiv rau yav tom ntej. Cov npe ntawm cov lej tseem ceeb koj pom raws li lub rooj hauv daim duab yog cov lej kuv tau txais thaum nias khawm ntawm kuv qhov pheej yig IR chaw taws teeb.

Koj tseem tuaj yeem nkag mus rau qhov chaws tiag tiag qhia tawm ntawm kuv tus Arduino web editor ntawm ir-key-code-logger.

Nco tseg: Tsis txhob ntshai yog tias koj pom tus lej zoo li FFFFFF qhov chaw nyob nruab nrab. Nws txhais tau tias koj tau nias thiab tuav lub pob rau ib pliag. Peb yuav rov qab los rau nws tom qab. Txog tam sim no tsuas yog tsis quav ntsej lawv thiab tsom mus rau lwm cov lej.

Kauj Ruam 6: Tswj Teeb ntawm LEDs Siv IR Chaw Taws Teeb

Tswj Teeb ntawm LEDs Siv IR Chaw Taws Teeb
Tswj Teeb ntawm LEDs Siv IR Chaw Taws Teeb
Tswj Teeb ntawm LEDs Siv IR Chaw Taws Teeb
Tswj Teeb ntawm LEDs Siv IR Chaw Taws Teeb
Tswj Teeb ntawm LEDs Siv IR Chaw Taws Teeb
Tswj Teeb ntawm LEDs Siv IR Chaw Taws Teeb

Tam sim no peb muaj tus lej rau txhua lub khawm, nws yog lub sijhawm tsom mus rau txoj hauv kev uas peb tuaj yeem siv lawv. Feem ntau koj siv IR chaw taws teeb xa cov lus txib rau Arduino ua qee yam xws li qhib lossis tua lub teeb, txav tus neeg hlau tshwj xeeb, qhia qee yam ntawm LCD/OLED screen, thiab lwm yam Ntawm no peb sim ua kom pom cov txheej txheem siv yooj yim. Circuit Court suav nrog 4 LEDs hauv cov xim sib txawv. Peb xav tig txhua tus ntawm lawv los yog tua los ntawm khawm tshwj xeeb ntawm IR chaw taws teeb. Raws li koj tuaj yeem pom ntawm cov txheej txheem, koj yuav tsum txuas Arduino raws li hauv qab no mus rau LEDs thiab sensor:

Arduino GND -> IR sensor GND.

Arduino VCC -> IR sensor VCC.

Arduino 13 -> IR sensor teeb liab tso tawm.

Arduino 2 -> Anode ntawm xiav LED (luv tus pin ntawm xiav LED)

Arduino 3 -> Anode ntawm ntsuab LED (luv tus pin ntawm ntsuab LED)

Arduino 4 -> Anode ntawm cov LED daj (luv tus pin ntawm cov xim daj LED)

Arduino 5 -> Anode ntawm lub liab LED (luv tus pin ntawm tus liab LED)

Arduino GND -> Cathode ntawm txhua lub LEDs ntawm 220 ohm resistor (tus pin ntev dua ntawm LEDs)

Koj tuaj yeem pom cov cai sib xws rau cov kab ke no hauv cov ntawv txuas lossis ntawm kuv tus Arduino web editor ntawm ir-led-control.

Kauj ruam 7: Troubleshooting

Thaum teeb tsa koj txoj haujlwm thiab ua raws cov kauj ruam koj yuav ntsib ntau yam xwm txheej txawv. Nov yog cov npe ntawm qee qhov yuam kev uas koj tuaj yeem tau txais thaum ua haujlwm nrog IR sensor.

Tau FFFFFF thaum nias tus yuam sij

Thaum nias lub pob koj yuav pom tias feem ntau nws tshaj tawm cov lej zoo li FFFFFF. Qhov no tshwm sim thaum koj nias lub pob thiab tuav nws ib pliag, txawm tias yog lub sijhawm luv luv. Qhov xwm txheej yog tias thaum koj nias lub pob pib, IR chaw taws teeb xa cov lej khawm thiab tsuav koj tuav lub pob, nws rov xa FFFFFF dua uas txhais tau tias tus neeg siv tseem tab tom nyem lub pob tshaj tawm tsis ntev los no. Qhov ntawd yuav OK. Koj tuaj yeem tshem tawm lawv. Qhov tseeb tus lej yog qhov koj tau txais ua ntej FFFFFF ntawm Serial Monitor.

IR Sensor tsis hnov mob hlo li thiab zoo li nws tau sov

Txiav lub zog !!! Yog tias koj paub tseeb tias tus lej yuam sij logger kos duab yog qhov raug, tom qab ntawd qhov teeb meem tej zaum yog vim teeb tsa tsis raug ntawm koj cov xov hlau. Qhov xwm txheej uas tshwm sim rau kuv yog qhov rau kuv tus qauv IR (ib qho txuas rau lub rooj tsavxwm) Kuv tau txuas VCC thiab GND hauv txoj kev rov qab (vim tsis siv xim zoo rau kuv cov xov txuas). Los ntawm kev ua li ntawd cov khoom siv hluav taws xob tau hlawv thiab cov pa luam yeeb xiav zoo. Kuv yuav ib pob ntawm cov nyoos IR sensors thiab sim hloov nws thiab tam sim no nws ua haujlwm zoo li ntxim nyiam:). Hmoov tsis zoo kuv tau ua yuam kev ib yam thaum kuv tau sim nrog cov nyoos IR sensor thiab lub sijhawm no tsis muaj dab tsi tshwm sim tshwj tsis yog tias lub ntsuas cua sov. Yog li nco ntsoov xyuas lub Circuit Court ua ntej tig lub zog!

Qee zaum lub ntsuas pom lub cim uas kuv tsis tau pom dua ua ntej

Nov yog ib qho ntawm cov teeb meem feem ntau. Feem ntau yuav yog vim ib qho ntawm cov hauv qab no:

Koj tsis tau taw koj li IR chaw taws teeb ncaj qha mus rau lub sensor

Qhov no yuav ua rau muaj qee tus lej tshiab (feem ntau yog cov lej ntev dua) uas koj tsis tau txais ua ntej thiab ib txwm tsis phim nrog qhov ntev ntawm cov lej koj twb muaj. Yog li nco ntsoov nco ntsoov taw tes rau tej thaj chaw deb ntawm koj lub sensor.

Koj siv tus IR pheej yig pheej yig (zoo li qhov kuv tau siv hauv qhov kev qhia no)

Hloov chaw ntawm kev siv tus nqi pheej yig uas tsis tuaj yeem kwv yees tau, koj tuaj yeem sim tib qhov xwm txheej uas siv koj lub TV lossis DVD Player chaw taws teeb tswj lossis IR chaw taws teeb ntawm txhua yam khoom siv uas koj muaj. Lawv ib txwm muaj lub teeb liab zoo/kho vajtse zoo (thiab tau kawg yog kim dua) thiab raws li kuv qhov kev paub, lawv ib txwm ua haujlwm zoo txawm tias koj tsis qhia koj lub chaw taws teeb ncaj qha mus rau lub sensor.

Kuv yuav ua li cas thiaj paub tias tus lej uas tau nkag mus tsis yog cov khib nyiab

Cov lej feem ntau nthuav tawm hauv hom hexadecimal. Yog tias koj hloov lawv mus rau tus nqi sib thooj sib xws, koj yuav pom tias qhov sawv cev binary ntawm qhov kawg byte yog qhov tsis zoo ntawm byte los ua ntej ntawd. Yog koj paub qhov no, koj tuaj yeem tshawb xyuas qhov no hauv koj tus lej kom paub tseeb tias cov cai koj tau txais yog qhov siv tau lossis tsis yog. Ua piv txwv, yog tias koj tau txais FF7A85 nws cov sawv cev binary yuav zoo li hauv qab no:

1111 1111 0111 1010 1000 0101

Los ntawm sab laug mus rau sab xis, txhua pawg ntawm 4 tus lej yog sawv cev ntawm tus ua cim hauv thawj tus lej hexadecimal. Raws li koj tuaj yeem pom, pawg sib xws rau 7 yog 0111 thiab pawg sib xws rau 8 yog 1000 uas yog qhov tsis pom tseeb ntawm nws. Los ntawm kev tsis pom zoo kuv txhais tau tias txhua 0s yuav yog 1s thiab txhua 1s yuav raug hloov los ntawm 0s. Tib yam muaj tseeb rau tus tom ntej uas yog A (1010) thiab 5 (0101).

Kauj Ruam 8: Yuav Ua Dab Tsi Ntxiv?

Tam sim no nws yog koj lub sijhawm. Nws yog txhua yam ntawm koj lub tswv yim kom pom tias koj tuaj yeem ua dab tsi nrog qhov ntsuas me me yooj yim hauv koj txhais tes. Nov yog qee cov tswv yim pib nrog:

  • Siv IR tswj chaw taws teeb ntawm ib qho ntawm cov khoom siv uas koj muaj hauv tsev (TV, Stereo, thiab lwm yam) thiab sim siv nws hauv koj qhov project Arduino
  • Sim qhib tag nrho cov LEDs ib zaug los ntawm nias tus yuam sij thiab tom qab ntawd tua lawv siv lwm tus yuam sij
  • Siv Up/Down khawm ntawm cov chaw taws teeb kom tig LEDs rau/tua ib qho los ntawm ib qho kom txog thaum lawv txhua tus qhib/tua
  • Tsim lub teeb pom kev siv cov LEDs thiab tswj nws siv koj lub chaw taws teeb
  • Yog tias koj muaj lub tshuab DC me me ntawm tes, sim pib/nres lossis hloov nws txoj kev sib hloov ntawm IR chaw taws teeb
  • Koj tuaj yeem siv koj lub TV tej thaj chaw deb los tswj koj lub neeg hlau lossis qhib/lov tes taw qee qhov ntsuas/ua haujlwm ntawm nws

Qhia rau kuv paub ntawm cov lus pom, koj yuav ua dab tsi (lossis koj twb tau ua tiav lawm) siv IR chaw taws teeb.

Pom zoo: