Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
I am posting this as it may useful to other people. I added AN217 to my project with of course a separate thread to do the monitoring (every second). I would rather simply look at the count to determine if the voltage is over or under some threshold.
Private Const threshold as UnsignedInteger = 514 ' 10V
My suggestion would be to change the readADC() function to return the unsigned integer count. For example purposes you can do the actual voltage calculation in Main as follows:
You may have misunderstood my intent. The original routine contains floating point math. I removed that math from the routine and used it outside only for displaying the output value for humans. For code purposes I suggested returning an integer and then do integer comparisons like this:
Private Const lowBattery as UnsignedInteger = 520 ' approx 10V (520/52 = 10)
voltage = ReadADC(monitorPin)
If voltage < lowBattery Then
Debug.Print "Low battery voltage"
End If