Processing is an easy-to-learn language for writing graphics programs based on Java.
You don't have to use Processing in this assignment, but you can.
The basic model to do this is as follows (I'll start with the simple unidirectional case where you are only sending data into Processing):
* You write Arduino code that sends data to an attached PC using the serial port functions.
* You write Processing code that opens the appropriate serial port on the PC and reads the data that your Arduino program sent; it then parses the data and responds appropriately.
* You have to come up with a protocol for your messages so Arduino and Processing agree on the format of the messages. This can be as simple as "send a single number followed by the newline character" and as complex as sending XML or JSON.
This is flexible, but also a lot of work: you have to define the protocol and write two pieces of code. Debugging these setups is also time consuming. In many cases, you only need to read simple analog or digital input pins, and write to output pins.
For this common case, Processing provides a library that consists of 1) A Processing library (called "Arduino") and 2) a special firmware (aka sketch) that you run on your Arduino board (called "Firmata"). Firmata exposes a simple, efficient protocol for reading and writing to pins. The Processing library then creates a wrapper around that protocol with Processing/Java functions that mimc the names of Arduino/C functions.
More information is here: http://www.arduino.cc/playground/Interfacing/Processing
No comments:
Post a Comment