Where you create a variable matters in code. If you create a variable inside the void loop, that variable will get reset to its starting value every time the loop runs.
In this program, that means your variable is getting set to 40 each time the loop runs, so it can't rise like it's supposed to. Check out the project page to remember where the variable should be created.