I have uploaded the following sketch, but the behaviour isn't what i would expect. Pin7 has a non-latching push-to-make switch attached, with the other pin connected to ground.
Now I would expect that once uploaded, the LED would be off, and when I shorted pin7 to ground, the LED would light up. But the behaviour is inverted - once uploaded, the LED is on, and shorting pin7 turns it off.
Can anyone give me any ideas as to why this doesn't work as I am expecting it to?
The need is to understand how you are electrical wiring up a button switch and how you implement a required pull-down or pull-up resistor for the input pin.
Just to explain a bit more, if you don't connect a pin to anything, it doesn't have any particular value. Basically it collects noise from nearby circuits, thus the flickering. You need to ensure it is either low (with an external pulldown) or high (with an internal or external pullup) and then take steps to change the value to the other one via your switch.