Hello, I am coding a macro. In short, the macro presses the 9w0w keys on the keyboard. But when I stop pressing the switch, it does not finish the loop. In other words, 9w0w is written like this every time. What should happen is that as long as I keep it pressed, it will be 9w0w9w0w9w0w, but when I stop pressing it, it may end like 9w0. Can you help me with this?
I missed what you mentioned because I was struggling with the problem so much. I updated my code. I still have the problem. The switch should work when pressed and stay where it is when I release it.
How are those wires connected? Are they just shoved through the holes? That won't make good contact. You need to solder them.
Why are you using analogRead and not digitalRead? The switch should give you either on or off, not anything in between.
When the footswitch is not pressed, black and white are connected inside so the pin A0 sees 0 volts.
What do you think is connected when the footswitch is not pressed? What should the pin read in that case? It looks like it is floating and can read anything it wants.
But everything works on the hardware side. When I run the codes I wrote above, when I press the switch, it writes 9w0w to the screen. But when I take my foot off the switch, it completes the loop. I want it to stop as soon as I take my foot off. @Delta_G@LarryD
Thank you. I thought about what you said and now it works without any problems. When I press it, the 9w0w macro works and when I take my foot off it stops. (So it doesn't force the loop to complete.)