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 Jun-25-2018 22:27:47 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: Friday Jul-13-2018 20:24:02 PDT
Buy It Now for only: $3.80
20PCS Photoresistor GL5528 LDR Photo Resistors FREE SHIPPING US SELLER
20PCS Photoresistor GL5528 LDR Photo Resistors FREE SHIPPING US SELLER $2.99
End Date: Thursday Jun-28-2018 20:09:24 PDT
Buy It Now for only: $2.99
20PCS Photoresistor GL5528 LDR Photo Resistors Light Dependent LW
20PCS Photoresistor GL5528 LDR Photo Resistors Light Dependent LW $0.99
End Date: Wednesday Jul-11-2018 11:35:09 PDT
Buy It Now for only: $0.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: Wednesday Jun-27-2018 8:22:19 PDT
Buy It Now for only: $4.75
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: Monday Jul-9-2018 10:57:35 PDT
Buy It Now for only: $0.99
US Stock 20pcs GL5549 5mm Photo Light Sensitive Resistor Photoresistor
US Stock 20pcs GL5549 5mm Photo Light Sensitive Resistor Photoresistor $6.01
End Date: Monday Jul-16-2018 0:04:04 PDT
Buy It Now for only: $6.01
20PCS Photoresistor GL5528 LDR Photo Resistors Light Dependent Best
20PCS Photoresistor GL5528 LDR Photo Resistors Light Dependent Best $0.74
End Date: Friday Jul-20-2018 10:34:20 PDT
Buy It Now for only: $0.74
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor $4.65
End Date: Saturday Jun-23-2018 14:19:39 PDT
Buy It Now for only: $4.65
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor $4.49
End Date: Saturday Jun-23-2018 2:38:04 PDT
Buy It Now for only: $4.49

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