Kana iwe wakambozvibvunza nzira yekuyera nenzira kwayo chiyero chechiedza munzvimbo ine Arduino, iwe uri munzvimbo chaiyo. Muchikamu chino, tichatsanangura nhanho nhanho kuti tingazviita sei uchishandisa LDR photoresistor, inozivikanwawo se photoresistor. Izvi zvidiki zvishamiso zvetekinoroji zvikamu zvemagetsi zvinokwanisa kushandura kuramba kwavo zvichienderana nehuwandu hwechiedza chavanogamuchira, icho chinovhura mikana isingaperi yemapurojekiti emagetsi uye otomatiki.
Mashandisirwo emagetsi emwenje ane Arduino akawanda: kubva otomatiki mwenje masisitimu kusvika kumarobhoti anozvitungamira pachiedza. Zvakanakisa zvezvose, chinhu chinokwanisika uye chiri nyore kushandisa. Pano isu tinokupa ruzivo rwese rwunodiwa kuitira kuti iwe ugone kuvaka yako wega yekuyera sisitimu neArduino uye kutora mukana wekugona kwayo kuzere.
Chii chinonzi LDR uye chinoshanda sei?
Una LDR (Chiedza Dependent Resistor) Iko kupikisa iyo hukuru hunosiyana zvichienderana nehuwandu hwechiedza chinowira pairi. Mumamiriro erima, kupokana kwakakwira zvakanyanya, kunosvika hunhu hunosvika 1 MOhm. Pane zvinopesana, kana LDR ikagamuchira chiedza chakawanda, kuramba kunoderera zvakanyanya, kusvika kune zvakakosha pakati pe50 kusvika ku100 Ohms pasi pechiedza chakasimba.
Kushanda kwayo kunobva pamusimboti we conductivity ye semiconductor zvinhu. Pakugashira chiedza, mafotoni anopa simba maerekitironi muzvinhu, achifambisa kuyerera kweazvino uye nokudaro kudzikira kuramba. Iyi mhando ye sensor inobatsira zvakanyanya kune maapplication uko chiyero chechiedza munzvimbo inodiwa.
LDR Features
Ichi chikamu chinofarirwa zvakanyanya nekuda kwemutengo wakaderera uye nyore kushandisa. Yakajairika kuramba tsika dzinobva 1 MOhm murima rakazara kusvika ku50-100 Ohm muchiedza chakajeka. Nekudaro, zvakakosha kuti titaure kuti haasi iwo chaiwo ma sensors kana iwe uchitsvaga kuyera chaizvo kujekesa (chiedza mu lux), sezvo ivo vachigona kukanganiswa nezvinhu zvakaita setembiricha.
Resistance musiyano inonoka, kutora pakati pe20 kusvika ku100 milliseconds zvichienderana nemuenzaniso. Izvi zvinoreva kuti haikodzeri kuona shanduko dzemwenje dzinokurumidza, dzakadai sedzinogadzirwa pasi pe AC-powered mwenje, asi inopa kugadzikana kwakanakisa mumamiriro ekugara achivhenekesa.
Nguva LDRs dzakanyanya kukodzera kuyera mwenje mafambiro kuti kupa data chaiyo, mutengo wavo wakaderera uye nyore kubatanidzwa nemabhodhi eArduino anovaita seyakanaka sensor yeDIY mapurojekiti.
Circuit uye Connection Diagram
Kuti Arduino ikwanise kuyera kusiyanisa kweLDR, zvinodikanwa kukwidza sensor pane inozivikanwa se voltage mugoveri. Iri rakareruka redunhu rinoumbwa neLDR uye yakagadziriswa resistor yakabatana munhevedzano. Iyo LDR inoiswa pakati peiyo yekuisa voltage (semuenzaniso 5V pabhodhi Arduino Uno) uye pini yekupinza yeanalogi, uye iyo yakagadziriswa resistor yakabatana pakati pepini nepasi (GND).
Iko kukosha kwekupikiswa kwakagadziriswa kunowanzo 10 kOhms, kunyangwe ichigona kusiyana zvichienderana nekunzwa kwaunoda kuwana muchiyero chako.
Gungano uye Code Mienzaniso
Kuvaka sisitimu yakakosha neArduino uye LDR, chinhu chekutanga chaunofanirwa kuita kubatanidza zvinotevera zvinhu:
- Imwe magumo eLDR kune iyo 5V inopa.
- Imwe magumo eLDR kune analog input (A0, semuenzaniso) uye panguva imwechete kune yakagadziriswa resistor iyo ichabatanidzwa pasi.
Nekuseta uku unogona kutanga kuverenga hunhu hunopihwa neLDR kuburikidza nekuisa analog. Iyo kodhi iri pazasi muenzaniso wekutanga wekuverenga iwo maitiro:
const int pinLDR = A0;
void setup() {
Serial.begin(9600); // Iniciar monitor serie}
void loop() {
int valorLDR = analogRead(pinLDR); // Leer valor de LDR
Serial.println(valorLDR); // Imprimir valor en monitor
delay(500);
}
Iyi kodhi inodhinda kukosha pakati pe0 (kureva kana pasina mwenje) uye 1023 (yakanyanya mwenje yakagamuchirwa). Aya maitiro anoenderana nechiedza chinonzwisiswa neLDR.
Maitiro ekupikisa sekushanda kwechiedza
Sezvatotaurwa, kushorwa kweLDR kunodzikira sezvo inogamuchira mwenje wakawanda. Kuwana a kuyerwa chaiko kwehuwandu hwechiedza, iwe unofanirwa kuziva kukosha kwekupokana kweLDR yako mumamiriro akasiyana emwenje.
Muiyo GL55 yakatevedzana, semuenzaniso, kukosha kunotangira pa5 kΩ kusvika pa200 kΩ pamberi pechiedza uye kubva pa500 kΩ kuenda ku10 MΩ munzvimbo dzakasviba. Aya maitiro anogona kusiyana kubva kune imwe modhi kuenda kune imwe, saka zvinogara zvichikurudzirwa kubvunza iyo sensor data sheet.
Chinhu chinonakidza cheLDR ndechekuti Kunzwa kwayo kwakanyanya muchikamu chechiedza chegirini che spectrum., inenge pawavelengths ye540 nm. Izvi zvinoreva kuti maLDR anopindura zviri nani kune chiedza chegirini pane zvimwe zvikamu zvezvinoonekwa.
Zvishandiso zvinoshanda
Izvo zvinogoneka zvekushandisa zveLDR zvakabatana neArduino zvinenge zvisingaperi. Pakati pezvinonyanya kushanda ndeye otomatiki mwenje masisitimu, uko dunhu rinogona kumisa kana kudzima mwenje zvichienderana neyakaonekwa mwenje mwero. Izvo zvinoshandiswa zvakare chiedza chinotevera marobhoti uye maotomatiki masisitimu epamba.
Iwe unogona, semuenzaniso, kugadzira sisitimu apo mwenje wemwenje unodzikira, mwenje we LED kutsiva kushaikwa kwechiedza. Heino muenzaniso wakapfava wekodhi:
int LDRPin = A0; // Pin para la LDR
int LEDPin = 13; // Pin para el LED
int threshold = 500; // Umbral para encender el LED
void setup() {
pinMode(LEDPin, OUTPUT);
pinMode(LDRPin, INPUT);}
void loop() {
int valorLuz = analogRead(LDRPin);
if (valorLuz < threshold) {
digitalWrite(LEDPin, HIGH); // Enciende el LED
} else {
digitalWrite(LEDPin, LOW); // Apaga el LED
}
delay(100);}
Ichi chirongwa chidiki chinoverenga kukosha kweLDR uye kana chiyero chechiedza chakaderera pane chikumbaridzo chakaiswa, chinobatidza LED. Zvikasadaro inodzima. Muenzaniso uri nyore asi unoshanda kwazvo mukuvhenekera otomatiki mapurojekiti.
Kuganhurirwa nedziviriro
Kunyangwe kushandiswa kweLDR kuri nyore kwazvo mumapurojekiti mazhinji, zvakakosha kuti titarise zvimwe zvazvinogumira:
- Izvo hazvina kunyatsojeka kana uri kutarisa kuyera kusimba chaiko kwechiedza mu lux.
- Maitiro ayo anogona kusiyana zvichienderana nekupisa.
- Vanoshanda zvakanyanya kuona shanduko huru muchiedza uye kwete kukurumidza kusiyana.