This is WINmill !

Johnparayno's picture

 

 
 
 
 
 
/**
 * THIS IS MY PROCESSING CODE
 * Took the main program from: Inheritance Processing Example
 * Changed the attributes to create a beautifull winmill
 * Did not change the code for arduino from the course website!
 *
 * This program is controlled by a Potentiometer, the speed of
 * the visual winmill along with the physical winmill is controlled
 * by turning the Pot
 */
 
SpinSpots spots;
 
 
// PROCESSING CODE
import processing.serial.*;
Serial port;
float brightness = 2;
 
void setup() {
  size(1000,1000);
  port = new Serial(this,"/dev/tty.usbmodemfd131", 9600);
  port.bufferUntil('\n');
  smooth();
 
  spots = new SpinSpots(width/2, height/2, -0.02, 33.0);
}
 
void draw() {
  background(500,0 , 0);   
  fill(225);
  spots.update();
  spots.display();
}
 
void serialEvent (Serial port) {
brightness = float(port.readStringUntil('\n'));
brightness = brightness / 100;
}
 
class Spin{
  float x, y, speed;
  float angle = 0.0;
  Spin(float xpos, float ypos, float s) {
    x = xpos;
    y = ypos;
    speed = s;
  }
  void update() {
    angle += speed;
  }
}
 
 
class SpinSpots extends Spin {
  float dim;
  SpinSpots(float x, float y, float s, float d) {
    super(x, y, s);
    dim = 250;
  }
  void display() {
    noStroke();
    pushMatrix();
    translate(x, y);
    angle += brightness/17;
    rect(-10, 20, 20, 350 );
    rotate(angle);
    ellipse(-dim/2, 0, 200, 50);
    ellipse(dim/2, 0, 200, 50);
    popMatrix();
  }
}
visualization
visual prototype feedback
0
Your rating: None