Code: Select all
void setdigit() // function to set digit up or down
{
while ( digitalRead( (update ) ) // while the update pin is true (high)
{
digit(); // display the number
if (digitalRead( countdown ) ) // check to see if we count up or down
{
num = num - 1; // if so, decrement number
if (num < 0 ) // reset to 9 if decrement < 0
{ // hence a signed integer was needed
num = 9;
}
}
else
{
num = num + 1; // increment number
if (num = 10) // reset to 0 if increment is greater than 9)
{
num = 0;
}
}
delay(500); // wait half second as a "thumb debounce"
}
EEPROM.write( 0, num ); // write number to internal EEPROM
}