Mouse and LED 1

Mouse position control LED intensity

import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
void setup() {
size(512, 512); // It is defined the window to move our mouse
arduino = new Arduino(this, Arduino.list()[0], 57600);
}
void draw() {
//Change window colour depending on the mouse X position
background(constrain(mouseX / 2, 0, 255));
// The value of the mouse X position is recorded and sent to analogic output 13
arduino.analogWrite(13, constrain(mouseX / 2, 0, 255));
// The value of the mouse Y position is recorded and sent to analogic output 9
arduino.analogWrite(9, constrain(255 – mouseY / 2, 0, 255));
}

Deixa un comentari

L'adreça electrònica no es publicarà Els camps necessaris estan marcats amb *

 

Un bloc a XTECBlocs