void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.write(analogRead(A0)/4);
delay(1);
}
And the processing code:
import processing.serial.*;
Serial myPort;
PImage logo;
int bgcolor = 0;
void setup(){
colorMode(HSB, 255);
logo = loadImage("http://arduino.cc/logo.png");
size(170, 116);
println("Avaliable serial ports:");
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
}
void draw(){
if (myPort.available() > 0) {
bgcolor = myPort.read();
println(bgcolor);
}
background(bgcolor, 255, 255);
image(logo, 0, 0);
}
I couldn't get logo.width and logo.height to work, so i just used 170 and 116.
the number 0, change it to the right port that your arduino is connected.
It didnt worked for me when it was 0, then i changed to 3(arduino was on COM3) didnt work either, 2 didnt work and 1 was the right one.