Looks like we have a lot to learn here...
No, it WON'T be two volts....
The ADC returns a number between zero and 1023 (because you are in 10-bit mode), where zero equals 0v on the ADC, and 1023 equals full-scale 5v on the ADC. Each click on the ADC scale represents 1/1023 ie a FRACTIONAL part of 5v.
So if 5v = 1023, then 2v will be two fifths of 1023 (namely 409).
So, if you want the trip point to be 2v and with a 10-bit ADC, your code should be...
Code:
Main:
ADCIN 3, mon ' Read channel AN3 to Mon
if mon > 409 then
hpwm 1,32,2000
else
hpwm 1,255,2000
endif
pause 1000
goto main
Bookmarks