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
##################################################################
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: Tuesday Jul-14-2020 9:16:07 PDT
Buy It Now for only: $2.25
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor $5.99
End Date: Wednesday Jul-29-2020 14:19:39 PDT
Buy It Now for only: $5.99
20 pcs Photoresistor LDR CDS 5mm Light Dependent Resistor Sensor GL5528 Arduino
20 pcs Photoresistor LDR CDS 5mm Light Dependent Resistor Sensor GL5528 Arduino $1.53
End Date: Friday Jul-10-2020 20:00:26 PDT
Buy It Now for only: $1.53
LDR Photoresistor Photoresistor Light Detection Sensor Module Arduino PIC PI 5V
LDR Photoresistor Photoresistor Light Detection Sensor Module Arduino PIC PI 5V $2.45
End Date: Friday Jul-31-2020 7:59:48 PDT
Buy It Now for only: $2.45
50Pcs 5 Types10Pcs Photoresistor Kit Dependent Light Resistor Ldr Pack ES
50Pcs 5 Types10Pcs Photoresistor Kit Dependent Light Resistor Ldr Pack ES $3.18
End Date: Monday Jul-27-2020 6:17:32 PDT
Buy It Now for only: $3.18
LDR Photoresistor Photoresistor Light Detection Sensor Module Arduino PIC PI 5V
LDR Photoresistor Photoresistor Light Detection Sensor Module Arduino PIC PI 5V $0.99
End Date: Tuesday Jul-21-2020 20:59:59 PDT
Buy It Now for only: $0.99
100 pcs Photoresistor LDR CDS 5mm Light Dependent Resistor Sensor GL5516 Arduino
100 pcs Photoresistor LDR CDS 5mm Light Dependent Resistor Sensor GL5516 Arduino $4.24
End Date: Sunday Jul-5-2020 0:24:54 PDT
Buy It Now for only: $4.24
20x Photoresistor GL5528 LDR Photo Resistors Light Dependent WF
20x Photoresistor GL5528 LDR Photo Resistors Light Dependent WF $2.18
End Date: Saturday Aug-1-2020 5:05:44 PDT
Buy It Now for only: $2.18
200PCS 5528 5MM 10K 20K Photoresistor Light Dependent Resistor Sensor GL5528
200PCS 5528 5MM 10K 20K Photoresistor Light Dependent Resistor Sensor GL5528 $16.99
End Date: Wednesday Jul-8-2020 13:22:30 PDT
Buy It Now for only: $16.99
50pcs 5539 5MM 30K 90K Photoresistor Light Dependent Resistor Sensor GL5539
50pcs 5539 5MM 30K 90K Photoresistor Light Dependent Resistor Sensor GL5539 $4.99
End Date: Monday Aug-3-2020 7:33:26 PDT
Buy It Now for only: $4.99

« 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>