• fullscreen
  • ArduinoDraw1_0.pde
  • //EJ Posselius - Processing.3 - 2011.12.02 - v4.2
    
    //import library for speaking to the serial port
    import processing.serial.*;
    
    //import arduino library
    import cc.arduino.*;
    
    //this variable tells processing which seral port your board is connected to
    int port = 0;
    int randD = 1;
    
    //create arduino instance for each board you are speaking to
    Arduino arduino;
    
    //int dialX, dialY;
    int x,y,d;
    
    void setup () {
      size(800,800);
      //setup the arduino instance by stating the serial port you will be using and the speed of the communication
      //in this case, on my macBook Pro, the first port on the list located at slot 0 is where my USB cable is plugged in
      arduino = new Arduino(this, Arduino.list()[port], 57600);
    
      noStroke();    
      x=width/2;
      y=height/2;
      d = 10;  
    
      background(0);  
      smooth();
    }
    
    void draw () {
          
          fill(0,8);
          rect(0,0,width,height);
          
          
          randD = round((random(0,30)/10)*(arduino.analogRead(0)+arduino.analogRead(1))/2);
          d = round(map(randD,0,1023,0, 30));
          x = round(map(arduino.analogRead(0), 0,1023,0.01,width-(d/2)));
          y = round(map(arduino.analogRead(1), 0,1023,0.01,height-(d/2)));
          
          ellipseMode(CENTER);
       
          for(float i=0.; i<2*PI; i+=0.01) {
    
            float a = map(sin(i+x), -1., 1.,0,width-(d));
            float b = map(cos(i+y), -1., 1., 0, height-(d));
          
          fill(255);
          ellipse((d/2)+a,(d/2)+b,d,d);
          
            }    
            
    }   
     
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    EJ Posselius plus+

    Etch-a-duino

    Add to Faves Me Likey@!
    You must login/register to add this sketch to your favorites.

    2 10 Ohm var-resistors on an Arduino control Ellipse paramaters

    You need to login/register to comment.