// To interact with the Arduino board, this Processing code uses the // "cc.arduino.*" library. Such libraries also exist for Max/MSP and // many other programming languages. // The Arduino board runs "SimpleDigitalFirmata" code supplied with // Arduino, so you don't need to write any Arduino code! // // This Processing code light up eight LEDs in sequence. The LEDs are // connected to the Arduino's digital i/o pins 2-7. Pins 0 and 1 cannot // be used, since they are needed for the serial communication. import processing.serial.*; // firmata requires a serial connection import cc.arduino.*; // the firmata library for processing int pinLed; // holds the Arduino pin with LED that is on Arduino my_arduino; // declare an object of type "Arduino" void setup() { println(Arduino.list()); // print a list of Arduinos connected to PC my_arduino = new Arduino(this, "COM3", 57600); // connect to Arduino board on COM3 at 57600 bps. for (pinLed=2; pinLed<8; pinLed++) { // set digital pins 0-7 on the Arduino to OUTPUT my_arduino.pinMode(pinLed, Arduino.OUTPUT); } } void draw() { my_arduino.digitalWrite(pinLed, Arduino.LOW); // turn off the LED that was last turned on pinLed = (pinLed + 1); // increment pinLed if (pinLed > 7) {pinLed = 2;} // loop over pins 2-7 my_arduino.digitalWrite(pinLed, Arduino.HIGH); // turn on the LED connected to pinLed delay(200); // wait 200 millisecs }