Using photoresistor with 10kohm resistance
-
I'm new here, a few hours ago i've received the fipy and im trying to get a value by the photoresistor,
the white cable between the photoresistor and resistor goes to pin 16 but i always get the value of 4095.0 even if i cover the photo or point it with the torch
then the red cable to 3V3 and black to GND
i've read that maybe this is caused by an incorrect time.sleep()
can someone pleas help me and explain me whats wrong?
thank you

import pycom import time import machine from machine import Pin adc = machine.ADC() apin = adc.channel(pin='P16') def reading(): avg = 0 _AVG_NUM = const(100) for _ in range (_AVG_NUM): avg += apin() avg /= _AVG_NUM return(avg) while True: analog_val = reading() print(analog_val) time.sleep(1) pass -
@matthew
look at attenuation
https://docs.pycom.io/chapter/firmwareapi/pycom/machine/ADC.html#adcchannel--pin-attnadcattn0db
tryADC.ATTN_11DB
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login