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
##################################################################
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor $4.75
End Date: Wednesday Dec-11-2019 7:22:19 PST
Buy It Now for only: $4.75
20 X 5mm Photoresistor GL5528 LDR Photo Resistor Light Dependent Resistor USA
20 X 5mm Photoresistor GL5528 LDR Photo Resistor Light Dependent Resistor USA $5.49
End Date: Monday Dec-9-2019 11:02:10 PST
Buy It Now for only: $5.49
5 Types 10 Pcs Photoresistor Dependent Light Resistor LDR Pack For Arduino Kit
5 Types 10 Pcs Photoresistor Dependent Light Resistor LDR Pack For Arduino Kit $1.98
End Date: Monday Dec-9-2019 18:45:11 PST
Buy It Now for only: $1.98
20pcs Photo Light Sensitive Resistor Photoresistor GL5516 CA
20pcs Photo Light Sensitive Resistor Photoresistor GL5516 CA $0.75
End Date: Sunday Dec-22-2019 20:20:22 PST
Buy It Now for only: $0.75
Photoresistor 5537 5mm Photoelectric Sensor Silver + Coffee 10 PCS
Photoresistor 5537 5mm Photoelectric Sensor Silver + Coffee 10 PCS $0.99 (1 Bid)
End Date: Friday Dec-6-2019 20:45:41 PST
10Pcs innocuous photoresistor 5mm 5800B LDR resistor light dependent BH
10Pcs innocuous photoresistor 5mm 5800B LDR resistor light dependent BH $4.99
End Date: Friday Jan-3-2020 21:42:36 PST
Buy It Now for only: $4.99
20Pcs Photo Light Sensitive Resistor Photoresistor Optoresistor 5mm GL5549 CA
20Pcs Photo Light Sensitive Resistor Photoresistor Optoresistor 5mm GL5549 CA $0.98
End Date: Wednesday Dec-11-2019 2:41:57 PST
Buy It Now for only: $0.98
LDR CDS Resistance Arduino Light Dependent Resistor Sensor GL5516
LDR CDS Resistance Arduino Light Dependent Resistor Sensor GL5516 $1.00
End Date: Thursday Dec-19-2019 19:24:03 PST
Buy It Now for only: $1.00
10 pcs Innocuous Photoresistor 5MM 5800B LDR Resistor Light Dependent
10 pcs Innocuous Photoresistor 5MM 5800B LDR Resistor Light Dependent $1.58
End Date: Tuesday Dec-24-2019 8:47:05 PST
Buy It Now for only: $1.58
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: Saturday Dec-14-2019 8:16:07 PST
Buy It Now for only: $2.25

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