Yes, I actually do, my point is increasing the number by 1 and as it seems I can't find a way. Something simple like this has to be possible.
It IS possible. Stupidly simple, even.
What, exactly, are you counting? Where do you actually try to increase a number by 1?
Try this:
int pressCount = 0;
int stockCount = 20;
byte prevState = LOW;
byte currState;
byte switchPin = 2;
void setup()
{
Serial.begin(115200);
pinMode(switchPin, INPUT);
}
void loop()
{
currState = digitalRead(switchPin);
if(currState != prevState)
{
if(currState == HIGH)
{
pressCount++; // Increment the count of presses
int plus = pressCount + stockCount;
Serial.print("plus = ");
Serial.println(plus);
}
}
prevState = currState;
}
Upload that code, and open the serial monitor. Set the baud rate to 115200.
Press the switch a few times.
Then, examine the code to see the one line I snuck in there that your code doesn't have.