import processing.serial.*; import cc.arduino.*; Arduino arduino; //load Arduino library int ledPin = 13; //without Firmata this would be declared in Arduino sketch void setup() { println(Arduino.list()); //list available ports - use USB port arduino = new Arduino(this, Arduino.list()[0]); // v2 //arduino = new Arduino(this, Arduino.list()[0], 57600); // v1 arduino.pinMode(ledPin, Arduino.OUTPUT); size(200, 200); noStroke(); frameRate(30); } void draw() { background (255); if (mouseOverRect() == true) { //if mouse over square fill(242, 204, 47); //yellow color arduino.digitalWrite(ledPin, Arduino.HIGH); //LED on } else { fill(0); //black color arduino.digitalWrite(ledPin, Arduino.LOW); //LED off } rect(50, 50, 100, 100); //draws the square } boolean mouseOverRect() { return ((mouseX >= 50) && (mouseX <= 150) && (mouseY >= 50) && (mouseY <= 150)); }