Thanks for posting this update,
v.4, updated on May 26, 2011: modified to be compatible with Arduino 1.0; added set() to set absolute potentiometer values.
typo on the website - hint it is the year
You might add a link in the header of the .cpp /.h file to this thread to discuss the functionality.
Did some refactoring to optimize the code as some checks were made double - just give it a look if you like it
also caught one bug in set() ==> if the _currentValue is unknown you may not do math with it I assume
change(DIGIPOT_DOWN, DIGIPOT_MAX_AMOUNT); //_currentValue should in fact be enough...?
void DigiPot::set(uint8_t value)
value = constrain(value, 0, DIGIPOT_MAX_AMOUNT);
if (_currentValue == DIGIPOT_UNKNOWN)
else if (_currentValue > value)
else if (_currentValue < value)
change(DIGIPOT_UP, value - _currentValue);
void DigiPot::increase(uint8_t amount)
void DigiPot::decrease(uint8_t amount)
Change() can be optimized by not allways doing amount steps automatically but check if _currentValue == 0 or max too. But it might make the code more complex.
I'll think it over..