Here you are.
import processing.serial.*;
Serial port;
int xval;
int yval;
int eheight;
int ewidth;
int moveX;
int moveY;
Ball Sphere1dropper;
Ball Sphere2dropper;
Ball Sphere3dropper;
Ball Sphere4dropper;
Ball Sphere5dropper;
Ball Sphere6dropper;
Ball Sphere7dropper;
Ball Sphere8dropper;
Ball Sphere9dropper;
Ball Sphere10dropper;
Ball Sphere11dropper;
Ball Sphere12dropper;
Ball Sphere13dropper;
Ball Sphere14dropper;
Ball Sphere15dropper;
Ball Sphere16dropper;
Ball Sphere17dropper;
Ball Sphere18dropper;
Ball Sphere19dropper;
Ball Sphere20dropper;
Ball Sphere21dropper;
Ball Sphere22dropper;
Ball Sphere23dropper;
Ball Sphere24dropper;
Ball Sphere25dropper;
Ball Sphere26dropper;
void setup(){
size(450,1000);
background(0);
smooth();
//String portName = Serial.list()[0];
//port = new Serial(this, portName, 9600);
Sphere1dropper = new Ball(45,-250,30,30);
Sphere2dropper = new Ball(135,-500,30,30);
Sphere3dropper = new Ball(225,-750,30,30);
Sphere4dropper = new Ball(315,-1000,30,30);
Sphere5dropper = new Ball(405,-1250,30,30);
Sphere6dropper = new Ball(45, -1500, 30, 30);
Sphere7dropper = new Ball(135,-1750, 30, 30);
Sphere8dropper = new Ball(225,-2000, 30, 30);
Sphere9dropper = new Ball(315,-2250, 30, 30);
Sphere10dropper = new Ball(405,-2500, 30, 30);
Sphere11dropper = new Ball(405,-2750, 30, 30);
Sphere12dropper = new Ball(225,-3000, 30, 30);
Sphere13dropper = new Ball(45,-3250, 30, 30);
Sphere14dropper = new Ball(405,-2500, 30, 30);
Sphere15dropper = new Ball(405,-2500, 30, 30);
Sphere16dropper = new Ball(405,-2500, 30, 30);
Sphere17dropper = new Ball(405,-2500, 30, 30);
Sphere18dropper = new Ball(405,-2500, 30, 30);
Sphere19dropper = new Ball(405,-2500, 30, 30);
Sphere20dropper = new Ball(405,-2500, 30, 30);
Sphere21dropper = new Ball(405,-2500, 30, 30);
Sphere22dropper = new Ball(405,-2500, 30, 30);
Sphere23dropper = new Ball(405,-2500, 30, 30);
Sphere24dropper = new Ball(405,-2500, 30, 30);
Sphere25dropper = new Ball(405,-2500, 30, 30);
Sphere26dropper = new Ball(405,-2500, 30, 30);
}
void draw(){
background(0);
send_info_to_arduino();
stroke(51,204,0); // 1st
fill(51,204,0);
Sphere1dropper.moveBall(0,5);
Sphere1dropper.drawBall();
Sphere6dropper.moveBall(0,5);
Sphere6dropper.drawBall();
Sphere13dropper.moveBall(0,5);
Sphere13dropper.drawBall();
stroke(255,0,0); // 2nd
fill(255,0,0);
Sphere2dropper.moveBall(0,5);
Sphere2dropper.drawBall();
Sphere7dropper.moveBall(0,5);
Sphere7dropper.drawBall();
stroke(255,255,0); // 3th
fill(255,255,0);
Sphere3dropper.moveBall(0,5);
Sphere3dropper.drawBall();
Sphere8dropper.moveBall(0,5);
Sphere8dropper.drawBall();
Sphere12dropper.moveBall(0,5);
Sphere12dropper.drawBall();
stroke(0,0,255); // 4th
fill(0,0,255);
Sphere4dropper.moveBall(0,5);
Sphere4dropper.drawBall();
Sphere9dropper.moveBall(0,5);
Sphere9dropper.drawBall();
stroke(153,102,0); // 5th
fill(153,102,0);
Sphere5dropper.moveBall(0,5);
Sphere5dropper.drawBall();
Sphere10dropper.moveBall(0,5);
Sphere10dropper.drawBall();
Sphere11dropper.moveBall(0,5);
Sphere11dropper.drawBall();
//these two shapes are the background
beginShape();
stroke(255);
strokeWeight(1);
line(90, 0, 90, 1900);
line(180, 0, 180, 1900);
line(270, 0, 270, 1900);
line(360, 0, 360, 1900);
line(0, 250, 450, 250);
line(0, 500, 450, 500);
line(0, 750, 450, 750);
line(0, 1000, 450, 1000);
endShape();
beginShape();
noFill();
strokeWeight(2);
stroke(51,204,0);
ellipse(45, 875, 45, 45);
stroke(255,0,0);
ellipse(135, 875, 45, 45);
stroke(255,255,0);
ellipse(225, 875, 45, 45);
stroke(0,0,255);
ellipse(315, 875, 45, 45);
stroke(153,102,0);
ellipse(405, 875, 45, 45);
endShape();
}
class Ball {
//these variables hold the position the ball is on the window and how big it is
int x;
int y;
int ellipseHeight;
int ellipseWidth;
//this is the constructor used to create a new ball object
Ball(int xval, int yval, int eheight, int ewidth) {
x = xval;
y = yval;
ellipseHeight = eheight;
ellipseWidth = ewidth;
}
//this function draws the ball
void drawBall() {
ellipse(x,y,ellipseWidth, ellipseHeight);
}
//this function moves the ball
void moveBall(int moveX, int moveY) {
x+=moveX;
y+=moveY;
}
}
void send_info_to_arduino()
{
if (Sphere1dropper.y > 850 && Sphere1dropper.y < 900){
//port.write(1);
ellipse(45, 475, 45, 45);
}
if (Sphere2dropper.y > 850 && Sphere2dropper.y < 900){
//port.write(1);
ellipse(135, 475, 45, 45);
}
if (Sphere3dropper.y > 850 && Sphere3dropper.y < 900){
ellipse(225, 475, 45, 45);
//port.write(1);
}
if (Sphere4dropper.y > 850 && Sphere4dropper.y < 900){
ellipse(315, 475, 45, 45);
//port.write(1);
}
if (Sphere5dropper.y > 850 && Sphere5dropper.y < 900){
ellipse(405, 475, 45, 45);
//port.write(1);
}
}import processing.serial.*;
Serial port;
int xval;
int yval;
int eheight;
int ewidth;
int moveX;
int moveY;
Ball Sphere1dropper;
Ball Sphere2dropper;
Ball Sphere3dropper;
Ball Sphere4dropper;
Ball Sphere5dropper;
Ball Sphere6dropper;
Ball Sphere7dropper;
Ball Sphere8dropper;
Ball Sphere9dropper;
Ball Sphere10dropper;
Ball Sphere11dropper;
Ball Sphere12dropper;
Ball Sphere13dropper;
Ball Sphere14dropper;
Ball Sphere15dropper;
Ball Sphere16dropper;
Ball Sphere17dropper;
Ball Sphere18dropper;
Ball Sphere19dropper;
Ball Sphere20dropper;
Ball Sphere21dropper;
Ball Sphere22dropper;
Ball Sphere23dropper;
Ball Sphere24dropper;
Ball Sphere25dropper;
Ball Sphere26dropper;
void setup(){
size(450,1000);
background(0);
smooth();
//String portName = Serial.list()[0];
//port = new Serial(this, portName, 9600);
Sphere1dropper = new Ball(45,-250,30,30);
Sphere2dropper = new Ball(135,-500,30,30);
Sphere3dropper = new Ball(225,-750,30,30);
Sphere4dropper = new Ball(315,-1000,30,30);
Sphere5dropper = new Ball(405,-1250,30,30);
Sphere6dropper = new Ball(45, -1500, 30, 30);
Sphere7dropper = new Ball(135,-1750, 30, 30);
Sphere8dropper = new Ball(225,-2000, 30, 30);
Sphere9dropper = new Ball(315,-2250, 30, 30);
Sphere10dropper = new Ball(405,-2500, 30, 30);
Sphere11dropper = new Ball(405,-2750, 30, 30);
Sphere12dropper = new Ball(225,-3000, 30, 30);
Sphere13dropper = new Ball(45,-3250, 30, 30);
Sphere14dropper = new Ball(405,-2500, 30, 30);
Sphere15dropper = new Ball(405,-2500, 30, 30);
Sphere16dropper = new Ball(405,-2500, 30, 30);
Sphere17dropper = new Ball(405,-2500, 30, 30);
Sphere18dropper = new Ball(405,-2500, 30, 30);
Sphere19dropper = new Ball(405,-2500, 30, 30);
Sphere20dropper = new Ball(405,-2500, 30, 30);
Sphere21dropper = new Ball(405,-2500, 30, 30);
Sphere22dropper = new Ball(405,-2500, 30, 30);
Sphere23dropper = new Ball(405,-2500, 30, 30);
Sphere24dropper = new Ball(405,-2500, 30, 30);
Sphere25dropper = new Ball(405,-2500, 30, 30);
Sphere26dropper = new Ball(405,-2500, 30, 30);
}
void draw(){
background(0);
send_info_to_arduino();
stroke(51,204,0); // 1st
fill(51,204,0);
Sphere1dropper.moveBall(0,5);
Sphere1dropper.drawBall();
if (Sphere1dropper.y > 1000) {
Sphere1dropper.y = 0;
}
Sphere6dropper.moveBall(0,5);
Sphere6dropper.drawBall();
Sphere13dropper.moveBall(0,5);
Sphere13dropper.drawBall();
stroke(255,0,0); // 2nd
fill(255,0,0);
Sphere2dropper.moveBall(0,5);
Sphere2dropper.drawBall();
Sphere7dropper.moveBall(0,5);
Sphere7dropper.drawBall();
stroke(255,255,0); // 3th
fill(255,255,0);
Sphere3dropper.moveBall(0,5);
Sphere3dropper.drawBall();
Sphere8dropper.moveBall(0,5);
Sphere8dropper.drawBall();
Sphere12dropper.moveBall(0,5);
Sphere12dropper.drawBall();
stroke(0,0,255); // 4th
fill(0,0,255);
Sphere4dropper.moveBall(0,5);
Sphere4dropper.drawBall();
Sphere9dropper.moveBall(0,5);
Sphere9dropper.drawBall();
stroke(153,102,0); // 5th
fill(153,102,0);
Sphere5dropper.moveBall(0,5);
Sphere5dropper.drawBall();
Sphere10dropper.moveBall(0,5);
Sphere10dropper.drawBall();
Sphere11dropper.moveBall(0,5);
Sphere11dropper.drawBall();
//these two shapes are the background
beginShape();
stroke(255);
strokeWeight(1);
line(90, 0, 90, 1900);
line(180, 0, 180, 1900);
line(270, 0, 270, 1900);
line(360, 0, 360, 1900);
line(0, 250, 450, 250);
line(0, 500, 450, 500);
line(0, 750, 450, 750);
line(0, 1000, 450, 1000);
endShape();
beginShape();
noFill();
strokeWeight(2);
stroke(51,204,0);
ellipse(45, 875, 45, 45);
stroke(255,0,0);
ellipse(135, 875, 45, 45);
stroke(255,255,0);
ellipse(225, 875, 45, 45);
stroke(0,0,255);
ellipse(315, 875, 45, 45);
stroke(153,102,0);
ellipse(405, 875, 45, 45);
endShape();
}
class Ball {
//these variables hold the position the ball is on the window and how big it is
int x;
int y;
int ellipseHeight;
int ellipseWidth;
//this is the constructor used to create a new ball object
Ball(int xval, int yval, int eheight, int ewidth) {
x = xval;
y = yval;
ellipseHeight = eheight;
ellipseWidth = ewidth;
}
//this function draws the ball
void drawBall() {
ellipse(x,y,ellipseWidth, ellipseHeight);
}
//this function moves the ball
void moveBall(int moveX, int moveY) {
x+=moveX;
y+=moveY;
}
}
void send_info_to_arduino()
{
if (Sphere1dropper.y > 850 && Sphere1dropper.y < 900){
print("port.write(1); " + Sphere1dropper.y + " ");
ellipse(45, 475, 45, 45);
}
if (Sphere2dropper.y > 850 && Sphere2dropper.y < 900){
ellipse(45, 475, 45, 45);
print("port.write(2);");
}
/*
if (Sphere3dropper.y > 850 && Sphere3dropper.y < 900){
port.write(1);
}
if (Sphere4dropper.y > 850 && Sphere4dropper.y < 900){
port.write(1);
}
if (Sphere5dropper.y > 850 && Sphere5dropper.y < 900){
port.write(1);
}
*/
}