The rip zero does not have an ADC, what are you measuring? The time to charge the cap until the pin flips from low to high? Then you discharge the cap?
If that is what you are doing, you will soon burning out the sense pin because you are dumping the full current load to the pin (output low). You should add a 300 ohm resistor from the photo resistor to that pin so the cap can't unload with zero impedance.
Dang. I didn't know that. I fixed it on the physical breadboard, and in all of the schematics as well.
Edit: Fixed. I had a question about if the Anode should be heading to the pins, but double-checked the breadboard and an led image showing the long pin is the Anode, and fixed my schematic. The schematic should be final, same with the pcb as well (though a second verification from someone here would help too).
And yes the code measures uses the LDR and retrieves the time it takes to go from low to high. And I'm using that as the variable to determine light values in the room.
(P.S. Thanks for being super helpful too
)!
Code:
--------------------
#defines the pin that goes to the circuit
pin_to_circuit = 7
# Function: def rc_time(pin_to_circuit)
# Description: This function displays the photoresistor's values by using the 'count' variable,
# and sets the led to flash either red, green, or blue depending on the values given.
def rc_time(pin_to_circuit):
count = 0
#Output on the pin for
GPIO.setup(pin_to_circuit, GPIO.OUT)
GPIO. output(pin_to_circuit, GPIO.LOW) # Edit: Put a space between GPIO. output because it turns it into an emoji on forum otherwise.
time.sleep(0.2)
#Change the pin back to input
GPIO.setup(pin_to_circuit, GPIO.IN)
#Count until the pin goes high
while (GPIO.input(pin_to_circuit) == GPIO.LOW):
count += 1
return count