I'm a Cococa developer, new on Arduino platform.
My problem is very simple (a noob one). I'm searching a way to communicate with my computer, to send some orders, execute commands or programs from my Arduino.
This code loop the button and wait until it pressed.
When pressed, a serial proxy (Xcode project based on the Arduino Serial Example sample code found on the website) read incoming text (here an "A") to launch trigger commands.
And it works, bravo!
But it's very slow, not valid for a real-time use. The serial console receive my char hardly less a second. I reduced all latency, sleep, delay values found in the proxy code but it's still too slow.
Is this behavior is normal?
If not, from where this latency come?
And finally, exists it another way to execute commands on computers?
In your sketch, if the button is HIGH (I assume you've got a pull-down wired to it) and "run_once" is false (as it will be at the start of your program), then you'll print an "A".
Now, you set "run_once" true, so you can never print another "A", regardless of the state of the button.
Now, connect the switch between pin 2 and ground.
When the switch is open, the input pin will read HIGH, and when the switch is closed, it will read LOW.