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 M266
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor M266 $3.50
End Date: Monday May-14-2018 0:56:51 PDT
Buy It Now for only: $3.50
20PCS Photoresistor LDR CDS 5mm Light Dependent Resistor Sensor GL5516 M265
20PCS Photoresistor LDR CDS 5mm Light Dependent Resistor Sensor GL5516 M265 $3.80
End Date: Monday May-14-2018 20:24:02 PDT
Buy It Now for only: $3.80
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor $4.75
End Date: Saturday Apr-28-2018 8:22:19 PDT
Buy It Now for only: $4.75
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 May-18-2018 4:10:35 PDT
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 $0.99
End Date: Thursday May-10-2018 10:57:35 PDT
Buy It Now for only: $0.99
20PCS Photoresistor GL5528 LDR Photo Resistors Light Dependent Popular QY
20PCS Photoresistor GL5528 LDR Photo Resistors Light Dependent Popular QY $4.09
End Date: Wednesday May-9-2018 9:02:43 PDT
Buy It Now for only: $4.09
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor $4.49
End Date: Thursday May-24-2018 2:38:04 PDT
Buy It Now for only: $4.49
10 pcs Innocuous Photoresistor 5MM 5800B LDR Resistor Light Dependent
10 pcs Innocuous Photoresistor 5MM 5800B LDR Resistor Light Dependent $1.58
End Date: Saturday May-19-2018 9:47:05 PDT
Buy It Now for only: $1.58
US Stock GL5539 20pcs GL5528 5mm Photo Light Sensitive Resistor Photoresistor
US Stock GL5539 20pcs GL5528 5mm Photo Light Sensitive Resistor Photoresistor $3.82
End Date: Thursday May-17-2018 0:03:17 PDT
Buy It Now for only: $3.82
12mm Light Sensitive Dependent Resistor CDS LDR Photoresistor 12528 GL12528
12mm Light Sensitive Dependent Resistor CDS LDR Photoresistor 12528 GL12528 $0.99
End Date: Monday May-21-2018 6:42:59 PDT
Buy It Now for only: $0.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>