Analogue Light Dependent Resistor (LDR)

Analogue Light Dependent Resistor LDRThe Raspberry Pi works on digital signals - one or off.  Analogue can be any value and normally the Raspberry Pi requires an Analogue to Digital converter.

I have one connected to a 2m length of cable and one connected to a 20cm length of cable.

Requires a 1uf Capacitor

Resource - http://learn.adafruit.com/basic-resistor-sensor-reading-on-raspberry-pi

Takes a parameter of RCpin.  This is the pin where the resistor is connected to.  I have 2 connected to the system, one inside, one out.  The inside sensor is basically dark all day.

###################################################################

def RCtime(RCpin):
    reading = 0
    GPIO.setup(RCpin, GPIO.OUT)
    GPIO.output(RCpin, GPIO.LOW)
    time.sleep(0.1)

    GPIO.setup(RCpin, GPIO.IN)
    # This takes about 1 millisecond per loop cycle
    while (GPIO.input(RCpin) == GPIO.LOW):
        reading += 1
        if reading > 200:
            break
    return reading

def pdslight(GPIOPIN):
    if debug:
        print("Reading light " + str(GPIOPIN))
    x=0
    loops=5
    for y in range(0,loops):
        x = x + RCtime(GPIOPIN)
    x = x/loops
    if debug:
        print("Reading light " + str(GPIOPIN) + " " + str(x) )
    return x
##################################################################
10pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor
10pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor $1.95
End Date: Thursday Jan-30-2020 12:01:59 PST
Buy It Now for only: $1.95
20pcs photoresistor LDR CDS 5mmlight dependent resistor sensor gl5537 arduino AT
20pcs photoresistor LDR CDS 5mmlight dependent resistor sensor gl5537 arduino AT $2.25
End Date: Monday Feb-3-2020 7:44:01 PST
Buy It Now for only: $2.25
5mm Resistance LDR CDS GL5516 Sensor Photoresistor Light Dependent Resistor
5mm Resistance LDR CDS GL5516 Sensor Photoresistor Light Dependent Resistor $0.76
End Date: Sunday Jan-19-2020 22:04:01 PST
Buy It Now for only: $0.76
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor $4.75
End Date: Tuesday Feb-11-2020 7:22:19 PST
Buy It Now for only: $4.75
100pc Photoresistor 10k 1M Ohm LDR Photo Resistors Light Dependent Resistor USA
100pc Photoresistor 10k 1M Ohm LDR Photo Resistors Light Dependent Resistor USA $8.95
End Date: Saturday Jan-18-2020 19:46:19 PST
Buy It Now for only: $8.95
5 PCs Photoresistor GL5537 LDR Photo Resistors Light Dependent Resistor US Selle
5 PCs Photoresistor GL5537 LDR Photo Resistors Light Dependent Resistor US Selle $2.25
End Date: Friday Feb-14-2020 8:16:07 PST
Buy It Now for only: $2.25
30PCS Photoresistor LDR CDS 5mm Light Dependent Resistor Sensor GL5516 Arduino D
30PCS Photoresistor LDR CDS 5mm Light Dependent Resistor Sensor GL5516 Arduino D $1.16
End Date: Sunday Jan-19-2020 9:57:35 PST
Buy It Now for only: $1.16
LDR Photoresistor Photoresistor Light Detection Sensor Module Arduino PIC PI 5V
LDR Photoresistor Photoresistor Light Detection Sensor Module Arduino PIC PI 5V $1.95
End Date: Friday Jan-31-2020 6:59:48 PST
Buy It Now for only: $1.95
10 pcs Innocuous Photoresistor 5MM 5800B LDR Resistor Light Dependent
10 pcs Innocuous Photoresistor 5MM 5800B LDR Resistor Light Dependent $1.58
End Date: Friday Jan-24-2020 8:47:05 PST
Buy It Now for only: $1.58
30PCS Photoresistor LDR CDS 5mm Light Dependent Resistor Sensor GL5516 ArduiZH
30PCS Photoresistor LDR CDS 5mm Light Dependent Resistor Sensor GL5516 ArduiZH $1.02
End Date: Wednesday Feb-5-2020 20:35:42 PST
Buy It Now for only: $1.02

« Previous12345...910

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>