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 LDR CDS 5mm Light Dependent Resistor Sensor GL5516 M265
20PCS Photoresistor LDR CDS 5mm Light Dependent Resistor Sensor GL5516 M265 $3.80
End Date: Sunday Nov-12-2017 21:58:12 PST
Buy It Now for only: $3.80
5 PCs Photoresistor GL5537 LDR Photo Resistors Light Dependent Resistor US Selle
5 PCs Photoresistor GL5537 LDR Photo Resistors Light Dependent Resistor US Selle $1.99
End Date: Saturday Nov-4-2017 17:12:58 PDT
Buy It Now for only: $1.99
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor $4.75
End Date: Monday Oct-30-2017 8:22:19 PDT
Buy It Now for only: $4.75
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: Sunday Nov-5-2017 6:27:36 PST
Buy It Now for only: $3.50
20Pcs Photoresistor LDR CDS 5mm Light Dependent Resistor Sensor GL5516 Arduino
20Pcs Photoresistor LDR CDS 5mm Light Dependent Resistor Sensor GL5516 Arduino $0.79
End Date: Sunday Oct-29-2017 23:37:33 PDT
Buy It Now for only: $0.79
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor $4.65
End Date: Thursday Oct-26-2017 14:19:39 PDT
Buy It Now for only: $4.65
20PCS Photoresistor LDR CDS 5mm Light Dependent Resistor Sensor GL5516 Arduino
20PCS Photoresistor LDR CDS 5mm Light Dependent Resistor Sensor GL5516 Arduino $0.99
End Date: Friday Oct-27-2017 12:14:38 PDT
Buy It Now for only: $0.99
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: Saturday Nov-11-2017 9:57:35 PST
Buy It Now for only: $0.99
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.56
End Date: Monday Nov-6-2017 18:45:11 PST
Buy It Now for only: $1.56
5pcs Photoresistor Photo LDR CDS 5mm Resistor Sensor GL5516 NO TRACKING
5pcs Photoresistor Photo LDR CDS 5mm Resistor Sensor GL5516 NO TRACKING $2.60
End Date: Monday Nov-13-2017 16:49:31 PST
Buy It Now for only: $2.60

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