firepot
simplest arduino && processing animation
Danny && me make it together, when you rotate the potentiometer, the face move from left to right.
code in arduino:
int analog0 = 0;
int val = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
val = analogRead(analog0);
val = val/4;
Serial.print(val, BYTE);
}
codes in processing:
import processing.serial.*;
Serial myPort;
PImage bg,face;
int fire;
void setup(){
size(334,447);
smooth();
frameRate(30);
bg = loadImage(”background.jpg”);
face = loadImage(”scared.gif”);
image(bg,0,0);
println(Serial.list());
myPort = new Serial(this,Serial.list()[0],9600);
}
void draw(){
image(bg,0,0);
image(face,width/2-120+fire,80);
}
void serialEvent(Serial myPort){
fire = int(myPort.read()/1.3);
println(fire);
}




No comments
Jump to comment form | comments rss [?] | trackback uri [?]