Saturday, November 7, 2009

005 analogRead circles [processing] update













import cc.arduino.*;//import libraries to comunicate with arduino thru serial port
import processing.serial.*;

Arduino myArduino;//declare myArduino as a name for your board

float value;//declare a variable to store input data

void setup() {//exactly the same as in arduino platform
size(600,600);//screen size
println(Arduino.list());//this will list all availible COM ports
myArduino = new Arduino(this, Arduino.list()[0], 57600); //instead of 0 put one you use
background(100);//background colour
smooth();//smooth edges
}

void draw(){//the same as loop in arduino software (code repeats endlessly)
fill(100,10);
noStroke();
rect(0,0,width,height);
value=5*(myArduino.analogRead(0));//that's how we get input from arduino now
stroke(255,100,100);
strokeWeight(3);
noFill();
ellipse(mouseX,mouseY,value,value);//draw a circle using value as a radius
}

No comments:

Post a Comment