Friday, November 4, 2011

Midterm01


import processing.serial.*;
import cc.arduino.*;
int sensorUsed = 0; //Set
this to whatever input sensor io pin you're using
PImage bird;
Arduino arduino;
void setup() {
size(400, 400);
arduino = new Arduino(this,
Arduino.list()[0], 57600);

for (int i = 0; i <= 13;
i++) //prepare all the pins for
receiving input
arduino.pinMode(i,
Arduino.INPUT);
imageMode(CENTER);
}
void draw() {
background(255);
fill(0, 0, 255);

//if the sensor switch
float sensorValue =
arduino.analogRead(sensorUsed);
float sensorValueMapped =
map (sensorValue, 0, 200, 500, width);
bird =
loadImage("Bwire.jpg");
image(bird, width/2,
height/2, sensorValueMapped, 400);

}

No comments:

Post a Comment