I tired your code, Jerson, and it didn't seem to work right, say the ADC had 2.5 volts applied, and then i turned the voltage up to 3 volts, the output would turn on and off, over and over, rather than toggle once, to show a change happened, and then stop. i changed the threshold value to account for any instabilty in my input voltage, and still no dice. and like a i said before, i need the circuit to "readjust automatically" so that it only cares that there is a positive increase in voltage by a certain value and reacts once and then resets, it shouldn't care what the original ADC value was, only that the value increased. so it would have to "dynamically" adjust itself. you would figure that you would take a reading, and then some miliseconds later, take another reading, subtract the first value from the second and that number would show a difference (if there is any), which would mean a positive change. if that value was over that of the threshold, then react. you would have to clamp that value to a number between 0 and 1023, so there wouldn't be a negative value and a roll over (or under, in this case) which i think is what Jerson's code showed, and i already tried the same thing, in a slightly different way, and neither work... but i could be, and probably am missing something! i really don't understand absolute values (only their vodka!) and how it applies here, all your saying is that the number can only have a certain maximum value right? so couldn't i use MAX?
Bookmarks