Objective: Use serial communication to track LED blink frequency by programming Arduino to receive command from Processing to blink LED for a number of times and number of cycles.
Source code for arduino can be downloaded here.
Source code for processing can be downloaded here.
Upload the arduino code into arduino with the LED connected, or you can use the little orange LED already installed on the board.
Make sure you choose the proper COM port and then run the processing code.
There will be no code needed in the draw loop() for this tutorial, as receiving of serial data are done by the serialEvent() function.
At this point Arduino will be sending the character 'A' to establish first contact. FYI, both arduino and processing doesnt look as it as an alphabet A but an ASCII character of number 65.
So when u click the run button in the processing IDE, processing will acknowledge receipt of 'A' and set the boolean variable firstcontact to true. Then it will send out the values of numBlinks and numCycles to arduino to blink the LED arccordingly. The boolean variable started is added to indicated the the blinking process has started and data sent back from arduino indicates the number of cycles of blinking that has already been done.
Email me at lazymanacc@gmail.com for any suggestions or clarifications. Thanks!