This is the first code I wrote for my UNO R3 just to feel out the functions and I've already got some jankiness. Throughout this description I am referring to the first two if statements one inside the other one.
I'm trying to increment
i every time the signal is activated and then
j is used to create a small space of time where the button being pressed will not increment
i. My problem is my if statement involving
j seem to be totally ignored. I've tried multiple configurations of the if statement structure to no avail.
Here is where things get interesting. So upon setting up the serial connection back to my PC to debug this irritating problem and printing out the actual value of
j (to see why it was triggering my if statement prematurely) it magically fixed the problem. It's like until the program literally acknowledges
j's value in the print statement it doesn't exist but if it does it works. Any ideas on this?
Note: the serial monitor in both picture depicts consecutive iterations with the signal activated the entire time.
This picture shows the serial monitor after running with the button pressed but the print statement commented out
This picture shows the serial monitor at a space where the button was pressed and held (same time frame as image 1) but in this one it increments
i to 3 and then continues incrementing
j. How is this happening?