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: Friday Dec-29-2017 7:22:19 PST
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 $1.99
End Date: Thursday Jan-4-2018 4:07:34 PST
Buy It Now for only: $1.99
5pcs Photoresistor Photo LDR CDS 5mm Resistor Sensor GL5516 NO TRACKING
5pcs Photoresistor Photo LDR CDS 5mm Resistor Sensor GL5516 NO TRACKING $2.34
End Date: Friday Jan-12-2018 16:49:31 PST
Buy It Now for only: $2.34
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: Wednesday Jan-10-2018 9:57:35 PST
Buy It Now for only: $0.99
20PCS Photoresistor GL5528 LDR Photo Resistors Light Dependent Best EA
20PCS Photoresistor GL5528 LDR Photo Resistors Light Dependent Best EA $0.77
End Date: Wednesday Jan-3-2018 23:02:03 PST
Buy It Now for only: $0.77
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: Tuesday Dec-26-2017 11:14:38 PST
Buy It Now for only: $0.99
PHOTORESISTOR LDR CDS 5MM LIGHT DEPENDENT RESISTOR SENSOR GL5516 ARDUINO 20PCS
PHOTORESISTOR LDR CDS 5MM LIGHT DEPENDENT RESISTOR SENSOR GL5516 ARDUINO 20PCS $0.99
End Date: Friday Jan-5-2018 1:30:43 PST
Buy It Now for only: $0.99
10 pcs LDR Light Dependent Photo Resistor Sensor 5mm GL5528 great for Arduino
10 pcs LDR Light Dependent Photo Resistor Sensor 5mm GL5528 great for Arduino $2.99
End Date: Friday Jan-12-2018 18:26:29 PST
Buy It Now for only: $2.99
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: Sunday Dec-17-2017 19:59:59 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: Friday Jan-5-2018 18:45:11 PST
Buy It Now for only: $1.56

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