• fullscreen
  • color_arduino_test.pde
  • import processing.serial.*;
    import cc.arduino.*;
    float myValue;
    
    Arduino arduino;
    int led1 = 9;
    int lsensor1 = 1;
    int i = 0;
    //int lsensor1 = 1;
    //int buttonmode = 0;
    
    void setup() {
      size(500,500);
      smooth ();
      noStroke();
      frameRate(100);
      println(Arduino.list());
      arduino = new Arduino(this,Arduino.list()[0],57600);
      arduino.pinMode(led1,Arduino.OUTPUT);
    }
    
    
    void draw() {
      background (50 + i/4, 255 - i, 20+i);
    
      fill (i, 50+i, 100);
      //Here's the sensor part:
      i=arduino.analogRead(lsensor1);
    
    
      if(i <100)
      {
        pushMatrix ();
        translate (mouseX, mouseY);
        rectMode(CENTER);
    
        rect(0,0,10+mouseX,10+mouseY);
        popMatrix ();
        //    arduino.digitalWrite(led1,Arduino.LOW); It's from Arduino code
      }
      else
      {   
        pushMatrix ();
        translate (mouseX, mouseY);
    
        ellipse(0,0,5 + mouseX/2 ,5 + mouseY/2);
        popMatrix ();
      }
    }
    
    

    code

    tweaks (0)

    about this sketch

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

    This sketch is saved as a draft and it is not published on the homepage and browse page.

    license

    advertisement


    Andrew Lazarow

    Arduino Color and Shape test

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

    This is a test where Stepen and I were playing with syncing our arduino boards to processing.

    If you put a sensor into your analog 0 pin of your arduino, it will change the background and fill color of the shapes.

    Meanwhile mouseX and mouseY determine the position and size of the ellipse or rectangle

    You need to login/register to comment.