Need help with an Arduino program

or a snappy version

int circleX, circleY;  
int circleSize = 50;
boolean circleOver = false;
boolean myswitch = false;

void setup() {
  size(640, 360);
  circleX = width/2+circleSize/2+10;
  circleY = height/2;
  ellipseMode(CENTER);
  noStroke();
}

void draw() {
  background(200,200,0);
  fill(200);
  ellipse(circleX, circleY, circleSize, circleSize); // switch
  if ( myswitch ) fill(0,200,0);
  else            fill(0,0,200);
  ellipse(100, 100, circleSize, circleSize);         // LED
}


void mousePressed() {
  if (overCircle(circleX, circleY, circleSize))     myswitch = ! myswitch;
}

boolean overCircle(int x, int y, int diameter) {
  if (sqrt(sq(x - mouseX) + sq(y - mouseY)) < diameter/2 )     return true;
  else                                                         return false;
}

and i hope to see the version where you talk to arduino soon!

2 Likes