Wednesday, October 20, 2010

read value from one analog input in Processing

import processing.serial.*;

Serial port;
float val;

void setup() {
size(800, 600);
String arduinoPort = Serial.list() [0];
port = new Serial(this, arduinoPort, 9600);
}

void draw() {
if (port.available() > 0) {
val = port.read();
// val = map(val, 0, 255, 0, height);
}

background(val);
}

No comments:

Post a Comment