Diana Thompson, Sustainable food

Sky Greens in Singapore


Vertical Farming. Big Idea.


Processing

On mouse-click the image is swapped to “hell yes” or “hell no” and the servo motor rotates accordingly.

IMG_4896 IMG_4895 IMG_4893 IMG_4894IMG_4897

import processing.serial.*;
import cc.arduino.*;
Arduino myArduino;

PImage[] imageName= new PImage[3]; //we have 3 images
int index=0;
int imageW, imageH;

void setup(){
size(700,700);

println(Arduino.list());
myArduino = new Arduino(this, “COM3”, 57600);

myArduino.pinMode(9, Arduino.SERVO);

imageW=650;
imageH=650;

for(int i=0; i<imageName.length; i++){ //length defines how many images, in this case =3
imageName[i]= loadImage(“imageName”+i+”.png”);
}

//imageName[0] = loadImage(*imagename0.png*);
}

void draw(){

if(mousePressed == true){
myArduino.servoWrite(9, 180);
fill(0);
}
else{
myArduino.servoWrite(9,0);
fill(255);
}

// image(imageName[index], width/2-200, height/2-200, 400,400);
image(imageName[index], width/2-imageW/2, height/2-imageH/2, imageW, imageH);

}

void mousePressed(){
index+=1;
if(index>=imageName.length){
index=0;
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s