Digital Input State Change Value

I am working on an electric power meter. My meter emits a light pulse at each 1000 Wh used. I have taped a LDR onto the meter. The rest resistance of the LDR is 235K and the ligt pulse resistance is 150K. I would like to use a voltage divider and i.e. pin 9 as a digital input. The question is, what should be the value of the other resistor in the voltage divider in order to cross the threshold value from 1 to 0. I have not been able to find a value for the threshold value anywhere. I am aware, that I could use an analog input, but I want to use the “callback function” or “pin9changed” in order to calculate the time between pulses.

As with all digital logic, there are two defined thresholds:

Vil(max): the maximum voltage where the input will be read as a zero. This is 0.3xVDD, ie 1.0v if you’re running the imp at 3.3v

Vih(min): the minimum voltage where the input will be read as a one. This is 0.7xVDD, ie 2.3v if you’re running the imp at 3.3v

The actual point where the imp, or any other CMOS logic, will see the 0>1 or 1>0 transition will be somewhere between these two, but the point will vary based on chip, temperature, etc. The range 1.0-2.3v is basically a no-man’s land and anything can happen there.

I use this photodiode board in combination with a laser beam on my analog meter.
I suppose it will work on a led too

+1 for using a laser in an imp project :slight_smile: