Mouse and LED 2

Mouse control switch on/off of a LED /* * it switch the led on when the mouse button and it is switch off when it is not pressed*/ import processing.serial.*; //Import the necessary libraries import cc.arduino.*; Arduino arduino; // Create the objet Arduino int ledPin = 13; // Design PIN number for LED void setup() { //Configure port and signals to work with size(200, 200); arduino = new Arduino(this, Arduino.list()[0], 57600); // Configure port as of 0 index, could be 1, 2,… arduino.pinMode(ledPin, Arduino.OUTPUT); // Configure PIN13 as output arduino.digitalWrite(ledPin, Arduino.HIGH); //Swith on the LED very shortly and only once, it is not necessary } void draw() { //Draw the interaction window if (mousePressed == true) { //Ask if the mouse button is pressed arduino.digitalWrite(13,Arduino.HIGH); // If you press the mouse button switch the LED on } else { arduino.digitalWrite(13,Arduino.LOW); // If you don’t press the mouse button switch the LED off } }

Leave a comment