Light Sensitive Dependent Resistor CDS LDR Photoresistor
En fotoresistor används för att mäta ljusstyrkor. Den kan användas till olika larm och lampor och fungerar genom en resistor tar emot ljus, beroende på hur stark ljusstyrkan är får en resistans att variera. Ju mer belysning desto mindre resistans.
Ett enkelt sätt att sätta ihop så en lampa blir beroende av ljusstyrkan kan se ut så här:
Och kodas så här:
/******************** * Program: Photocell simple testing sketch. * Connect one end of the photocell to 5V, the other end to Analog 0. * Then connect one end of a 10K resistor from Analog 0 to ground * For more information see http://learn.adafruit.com/photocells ********************/ int photocellPin = A0; // the cell and 10K pulldown are connected to A0 int photocellReading; // the analog reading from the analog resistor divider void setup() { // We'll send debugging information via the Serial monitor Serial.begin(38400); } void loop() { photocellReading = analogRead(photocellPin); Serial.print("Analog reading = "); Serial.print(photocellReading); // the raw analog reading // We'll have a few threshholds, qualitatively determined if (photocellReading < 10) { Serial.println(" - Black"); } else if (photocellReading < 200) { Serial.println(" - Dark"); } else if (photocellReading < 500) { Serial.println(" - Light"); } else if (photocellReading < 800) { Serial.println(" - Luminous"); } else { Serial.println(" - Bright"); } delay(2000); } Källor: https://www.ebay.com/itm/4PCS-12mm-Light-Sensitive-Dependent-Resistor-CDS-LDR-Photoresistor-12528-GL12528/192113579043?_trkparms=aid%3D1110002%26algo%3DSPLICE.SOI%26ao%3D1%26asc%3D20200116171858%26meid%3Dec3ded18fdb045a891a00900ce8400d2%26pid%3D100008%26rk%3D1%26rkt%3D12%26mehot%3Dag%26sd%3D193150210093%26itm%3D192113579043%26pmt%3D1%26noa%3D0%26pg%3D2047675%26algv%3DPromotedSellersOtherItemsV2&_trksid=p2047675.c100008.m2219 https://diy.waziup.io/sensors/light/photoresistor.html http://www.studera.com/tranano/fysik/Elektricitet/Fotores.html