I added Buttons for Fan On/Off on Processing

Hello everyone,
I created Step Motor and Led System with Arduino and Processing. I added a Fan on my system. I added Buttons for Fan On/Off on Processing. I added Status. I want to this. If Fan is Active, Button will be green. If Fan is Inactive, Button will be red. I did something but didn’t be my want like. You have to see photo for understand me. I will share photo and codes under the topic…

import processing.serial.*;

Serial myStepMotor;

int buttonA_x = 20;
int buttonA_y = 50;
int buttonA_width = 185;
int buttonA_height = 130;
int buttonA_colorR = 0x25;
int buttonA_colorG = 0x25;
int buttonA_colorB = 0x25;

int buttonB_x = 20;
int buttonB_y = 190;
int buttonB_width = 185;
int buttonB_height = 130;
int buttonB_colorR = 0x25;
int buttonB_colorG = 0x25;
int buttonB_colorB = 0x25;

int buttonC_x = 20;
int buttonC_y = 330;
int buttonC_width = 185;
int buttonC_height = 130;
int buttonC_colorR = 0x25;
int buttonC_colorG = 0x25;
int buttonC_colorB = 0x25;

int buttonD_x = 20;
int buttonD_y = 470;
int buttonD_width = 185;
int buttonD_height = 130;
int buttonD_colorR = 0x25;
int buttonD_colorG = 0x25;
int buttonD_colorB = 0x25;

int buttonE_x = 20;
int buttonE_y = 610;
int buttonE_width = 185;
int buttonE_height = 130;
int buttonE_colorR = 0x25;
int buttonE_colorG = 0x25;
int buttonE_colorB = 0x25;

int buttonF_x = 20;
int buttonF_y = 750;
int buttonF_width = 185;
int buttonF_height = 130;
int buttonF_colorR = 0x25;
int buttonF_colorG = 0x25;
int buttonF_colorB = 0x25;

int buttonG_x = 20;
int buttonG_y = 890;
int buttonG_width = 90;
int buttonG_height = 120;
int buttonG_colorR = 0x25;
int buttonG_colorG = 0x25;
int buttonG_colorB = 0x25;

int buttonH_x = 115;
int buttonH_y = 890;
int buttonH_width = 90;
int buttonH_height = 120;
int buttonH_colorR = 0x25;
int buttonH_colorG = 0x25;
int buttonH_colorB = 0x25;

int buttonI_x = 1700;
int buttonI_y = 850;
int buttonI_width = 200;
int buttonI_height = 75;
int buttonI_colorR = 0x25;
int buttonI_colorG = 0x25;
int buttonI_colorB = 0x25;

int buttonJ_x = 1700;
int buttonJ_y = 935;
int buttonJ_width = 200;
int buttonJ_height = 75;
int buttonJ_colorR = 0x25;
int buttonJ_colorG = 0x25;
int buttonJ_colorB = 0x25;

int d = day();    // Values from 1 - 31
int m = month();  // Values from 1 - 12
int y = year();   // 2003, 2004, 2005, etc.

int defaultColor = 125;

boolean buttonA_clicked = true;
boolean buttonB_clicked = true;
boolean buttonC_clicked = true;
boolean buttonD_clicked = true;
boolean buttonE_clicked = true;
boolean buttonF_clicked = true;
boolean buttonG_clicked = true;
boolean buttonH_clicked = true;
boolean buttonI_clicked = true;
boolean buttonJ_clicked = true;

int valueA = 0;
int valueB = 1;
int valueC = 2;
int valueD = 3;
int valueE = 4;
int valueF = 5;
int valueG = 6;
int valueH = 7;
int valueI = 8;
int valueJ = 9;

void setup() {
  fullScreen();
  
  background(125, 125, 125);
  
  String StepMotor = Serial.list()[0];
  
  println(StepMotor);
  
  myStepMotor = new Serial(this, StepMotor, 9600);
  
  fill(0, 0, 0);
  text("(ESC) PRESS TO EXIT", 1790, 20);
  
  fill(0, 0, 0);
  text("/", 1867, 1070);

  fill(0, 0, 0);
  text("/", 1878, 1070);
  
  String s = String.valueOf(d);
  text(s, 1852, 1070);
  s = String.valueOf(m);
  text(s, 1871, 1070); 
  s = String.valueOf(y);
  text(s, 1883, 1070);
}
  void draw() {
  
   
  if(buttonA_clicked){
    fill(buttonA_colorR, buttonA_colorG, buttonA_colorB);
  }else 
  if(buttonB_clicked){
    fill(buttonB_colorR, buttonB_colorG, buttonB_colorB);
  }else
  if(buttonC_clicked){
    fill(buttonC_colorR, buttonC_colorG, buttonC_colorB);
  }else
  if(buttonD_clicked){
    fill(buttonD_colorR, buttonD_colorG, buttonD_colorB);
  }else
  if(buttonE_clicked){
    fill(buttonE_colorR, buttonE_colorG, buttonE_colorB);
  }else
  if(buttonF_clicked){
    fill(buttonF_colorR, buttonF_colorG, buttonF_colorB);
  }else
  if(buttonG_clicked){
    fill(buttonG_colorR, buttonG_colorG, buttonG_colorB);
  }else
  if(buttonH_clicked){
    fill(buttonH_colorR, buttonH_colorG, buttonH_colorB);
  }else
  if(buttonI_clicked){
    fill(buttonI_colorR, buttonI_colorG, buttonI_colorB);
  }else
  if(buttonJ_clicked){
    fill(buttonJ_colorR, buttonJ_colorG, buttonJ_colorB);
  }
  
  fill(buttonA_colorR, buttonA_colorG, buttonA_colorB);
  rect(buttonA_x, buttonA_y, buttonA_width, buttonA_height);
   
  fill(buttonB_colorR, buttonB_colorG, buttonB_colorB);
  rect(buttonB_x, buttonB_y, buttonB_width, buttonB_height);
  
  fill(buttonC_colorR, buttonC_colorG, buttonC_colorB);
  rect(buttonC_x, buttonC_y, buttonC_width, buttonC_height);
  
  fill(buttonD_colorR, buttonD_colorG, buttonD_colorB);
  rect(buttonD_x, buttonD_y, buttonD_width, buttonD_height);
  
  fill(buttonE_colorR, buttonE_colorG, buttonE_colorB);
  rect(buttonE_x, buttonE_y, buttonE_width, buttonE_height);
  
  fill(buttonF_colorR, buttonF_colorG, buttonF_colorB);
  rect(buttonF_x, buttonF_y, buttonF_width, buttonF_height);
  
  fill(buttonG_colorR, buttonG_colorG, buttonG_colorB);
  rect(buttonG_x, buttonG_y, buttonG_width, buttonG_height);
  
  fill(buttonH_colorR, buttonH_colorG, buttonH_colorB);
  rect(buttonH_x, buttonH_y, buttonH_width, buttonH_height);
  
  fill(buttonI_colorR, buttonI_colorG, buttonI_colorB);
  rect(buttonI_x, buttonI_y, buttonI_width, buttonI_height);
  
  fill(buttonJ_colorR, buttonJ_colorG, buttonJ_colorB);
  rect(buttonJ_x, buttonJ_y, buttonJ_width, buttonJ_height);
  
  textAlign(CENTER, CENTER); 
  
  fill(255);
  text("UP", 
    buttonA_x+buttonA_width/2, buttonA_y+buttonA_height/2);

  fill(255); 
  text("DOWN", 
    buttonB_x+buttonB_width/2, buttonB_y+buttonB_height/2);
    
  fill(255);
  text("STOP", 
  buttonC_x+buttonC_width/2, buttonC_y+buttonC_height/2);
  
  fill(255);
  text("TURN ON", 
  buttonD_x+buttonC_width/2, buttonD_y+buttonD_height/2);
  
  fill(255);
  text("TURN OFF", 
  buttonE_x+buttonC_width/2, buttonE_y+buttonD_height/2);
  
  fill(255);
  text("HOME", 
  buttonF_x+buttonF_width/2, buttonF_y+buttonF_height/2);
  
  fill(255);
  text("↑50",
  buttonG_x+buttonG_width/2, buttonG_y+buttonG_height/2);
  
  fill(255);
  text("↓50",
  buttonH_x+buttonH_width/2, buttonH_y+buttonH_height/2);
  
  fill(255);
  text("ACTIVE",
  buttonI_x+buttonI_width/2, buttonI_y+buttonI_height/2);
  
  fill(255);
  text("INACTIVE",
  buttonJ_x+buttonJ_width/2, buttonJ_y+buttonJ_height/2);
     
  fill(255,0,0);    
  ellipse(1870, 889, 15, 15);
  
  fill(255,0,0);    
  ellipse(1870, 974, 15, 15);
}

void mouseClicked(){
  // mouseX = x of mouse click position
  // mouseY = y of mouse click position

  if (mouseX >= buttonA_x && mouseX <= buttonA_x + buttonA_width && 
      mouseY >= buttonA_y && mouseY <= buttonA_y + buttonA_height) {
     buttonA_clicked = true;
     
     myStepMotor.write("1");
     print("1");
   } else {
     buttonA_clicked = false;
   }
    
   if (mouseX >= buttonB_x && mouseX <= buttonB_x + buttonB_width && 
       mouseY >= buttonB_y && mouseY <= buttonB_y + buttonB_height) {
     buttonB_clicked = true;
     
     myStepMotor.write("0");
     print("0");
   } else {
     buttonB_clicked = false;
   }
   
     if (mouseX >= buttonC_x && mouseX <= buttonC_x + buttonC_width && 
      mouseY >= buttonC_y && mouseY <= buttonC_y + buttonC_height) {
     buttonC_clicked = true;
     
     myStepMotor.write("2");
     print("2");
   } else {
     buttonC_clicked = false;
   }
   
     if (mouseX >= buttonD_x && mouseX <= buttonD_x + buttonD_width && 
      mouseY >= buttonD_y && mouseY <= buttonD_y + buttonD_height) {
     buttonD_clicked = true;
     
     myStepMotor.write("3");
     print("3");
   } else {
     buttonD_clicked = false;
   }
   
     if (mouseX >= buttonE_x && mouseX <= buttonE_x + buttonE_width && 
      mouseY >= buttonE_y && mouseY <= buttonE_y + buttonE_height) {
     buttonE_clicked = true;
     
     myStepMotor.write("4");
     print("4");
   } else {
     buttonE_clicked = false;
   }
     if (mouseX >= buttonF_x && mouseX <= buttonF_x + buttonF_width && 
      mouseY >= buttonF_y && mouseY <= buttonF_y + buttonF_height) {
     buttonF_clicked = true;
     
     myStepMotor.write("5");
     print("5");
   } else {
     buttonF_clicked = false;
   }
   
     if (mouseX >= buttonG_x && mouseX <= buttonG_x + buttonG_width && 
      mouseY >= buttonG_y && mouseY <= buttonG_y + buttonG_height) {
     buttonG_clicked = true;
     
     myStepMotor.write("6");
     print("6");
   } else {
     buttonG_clicked = false;
   }
   
     if (mouseX >= buttonH_x && mouseX <= buttonH_x + buttonH_width && 
      mouseY >= buttonH_y && mouseY <= buttonH_y + buttonH_height) {
     buttonH_clicked = true;
     
     myStepMotor.write("7");
     print("7");
   } else {
     buttonH_clicked = false;
   }  

     if (mouseX >= buttonI_x && mouseX <= buttonI_x + buttonI_width && 
      mouseY >= buttonI_y && mouseY <= buttonI_y + buttonI_height) {
     buttonI_clicked = true;
     fill(0,255,0);
     ellipse(1870, 889, 15, 15);
     myStepMotor.write("8");
     print("8");
   } else {
     buttonI_clicked = false;
   }
     if (mouseX >= buttonJ_x && mouseX <= buttonJ_x + buttonJ_width && 
      mouseY >= buttonJ_y && mouseY <= buttonJ_y + buttonJ_height) {
     buttonJ_clicked = true;
     fill(0,255,0);
     ellipse(1870, 974, 15, 15);
     myStepMotor.write("9");
   } else {
     buttonJ_clicked = false;
   }
}

Ek%20A%C3%A7%C4%B1klama%202019-07-25%20161946

Before fill insert an

if( FanIsInactive )
     fill(....
     else fill(.....

And use your appropriate variable name

So the entire structure:

if(buttonA_clicked){ 

   if( FanisInactive )
        fill(....
        else fill(.....

} else

Thank you for reading and returning.
I did your say. It give me Error. Where I did wrong? Could you rewrite for me??

  if (mouseX >= buttonJ_x && mouseX <= buttonJ_x + buttonJ_width && 
    mouseY >= buttonJ_y && mouseY <= buttonJ_y + buttonJ_height) {
    if (buttonJ_clicked) {
      if ( FanisInactive );
      fill(0, 255, 0);
      ellipse(1870, 974, 15, 15);
    } else {
      fill(255, 0, 0);
      ellipse(1870, 974, 15, 15);
      myStepMotor.write("9");
      print("9");
    } else {
      buttonI_clicked = false;
    }
  }
}

no semicolon ; at this place!!

It ends the condition!!

Use ctrl-t for auto-indents to spot those cases

Also you need a {

Please check the { } using ctrl-t

Where is the wrong?

  if (mouseX >= buttonD_x && mouseX <= buttonD_x + buttonD_width && 
    mouseY >= buttonD_y && mouseY <= buttonD_y + buttonD_height) {
    if (buttonD_clicked) {
      if ( FanisActive ) {
      }
      fill(255, 0, 0);
      ellipse(280, 535, 15, 15);
      myStepMotor.write("3");
      print("3");
    } else {
      buttonD_clicked = false;
    }
  }

“FanisActive cannot be resolved to a variable”

Here the brackets are wrong. They must enclose the code section that you want to be executed when the if condition is true

I made this name up.

Do you already have a variable that indicates whether the fan is active? Then use it here.

Otherwise you should declare the variable before setup ().

Could you rewrite for me just this part

  if (mouseX >= buttonD_x && mouseX <= buttonD_x + buttonD_width && 
    mouseY >= buttonD_y && mouseY <= buttonD_y + buttonD_height) {
    if (buttonD_clicked) {
      if ( FanActive ) {
      }
      fill(255, 0, 0);
      ellipse(280, 535, 15, 15);
      myStepMotor.write("3");
      print("3");
    } else {
    }
  }

How can I define variable before setup()?

Should I use String?

??

How do you switch your fan on and off now?

Does this work already?

Okay! Okay! 1 minutes. I use led. This is easy. I must define to use variable. I can define variable with int. Am I right?

No, please use boolean

I can create ellipse and add fill. I need to define variable. Could you rewrite me for define variable?

Okay! What I should write?

boolean fanIsActive=false;

OKay, I got it working now

at the end of draw you are drawing the ellipses

you want to change these, right?

Do this


  if (fanIsActive)
    fill(2, 255, 0);
  else 
  fill(255, 0, 2);
  ellipse(1870, 889, 15, 15);

  if (fanIsActive)
    fill(255, 0, 0);
  else 
  fill(0, 245, 0);  
  ellipse(1870, 974, 15, 15);

Before setup say boolean…

AND

at the very end of your sketch where you check buttonI and J say (see !!!)

 if (mouseX >= buttonI_x && mouseX <= buttonI_x + buttonI_width && 
    mouseY >= buttonI_y && mouseY <= buttonI_y + buttonI_height) {
    buttonI_clicked = true;
    fill(0, 255, 0);
    ellipse(1870, 889, 15, 15);
    myStepMotor.write("8");
    fanIsActive=true;   // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    print("8");
  } else {
    buttonI_clicked = false;
  }
  if (mouseX >= buttonJ_x && mouseX <= buttonJ_x + buttonJ_width && 
    mouseY >= buttonJ_y && mouseY <= buttonJ_y + buttonJ_height) {
    buttonJ_clicked = true;
    fill(0, 255, 0);
    ellipse(1870, 974, 15, 15);
    fanIsActive=false;   // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    myStepMotor.write("9");
  } else {
    buttonJ_clicked = false;
  }

running sketch

import processing.serial.*;

boolean fanIsActive=false; 

Serial myStepMotor;

int buttonA_x = 20;
int buttonA_y = 50;
int buttonA_width = 185;
int buttonA_height = 130;
int buttonA_colorR = 0x25;
int buttonA_colorG = 0x25;
int buttonA_colorB = 0x25;

int buttonB_x = 20;
int buttonB_y = 190;
int buttonB_width = 185;
int buttonB_height = 130;
int buttonB_colorR = 0x25;
int buttonB_colorG = 0x25;
int buttonB_colorB = 0x25;

int buttonC_x = 20;
int buttonC_y = 330;
int buttonC_width = 185;
int buttonC_height = 130;
int buttonC_colorR = 0x25;
int buttonC_colorG = 0x25;
int buttonC_colorB = 0x25;

int buttonD_x = 20;
int buttonD_y = 470;
int buttonD_width = 185;
int buttonD_height = 130;
int buttonD_colorR = 0x25;
int buttonD_colorG = 0x25;
int buttonD_colorB = 0x25;

int buttonE_x = 20;
int buttonE_y = 610;
int buttonE_width = 185;
int buttonE_height = 130;
int buttonE_colorR = 0x25;
int buttonE_colorG = 0x25;
int buttonE_colorB = 0x25;

int buttonF_x = 20;
int buttonF_y = 750;
int buttonF_width = 185;
int buttonF_height = 130;
int buttonF_colorR = 0x25;
int buttonF_colorG = 0x25;
int buttonF_colorB = 0x25;

int buttonG_x = 20;
int buttonG_y = 890;
int buttonG_width = 90;
int buttonG_height = 120;
int buttonG_colorR = 0x25;
int buttonG_colorG = 0x25;
int buttonG_colorB = 0x25;

int buttonH_x = 115;
int buttonH_y = 890;
int buttonH_width = 90;
int buttonH_height = 120;
int buttonH_colorR = 0x25;
int buttonH_colorG = 0x25;
int buttonH_colorB = 0x25;

int buttonI_x = 1700;
int buttonI_y = 850;
int buttonI_width = 200;
int buttonI_height = 75;
int buttonI_colorR = 0x25;
int buttonI_colorG = 0x25;
int buttonI_colorB = 0x25;

int buttonJ_x = 1700;
int buttonJ_y = 935;
int buttonJ_width = 200;
int buttonJ_height = 75;
int buttonJ_colorR = 0x25;
int buttonJ_colorG = 0x25;
int buttonJ_colorB = 0x25;

int d = day();    // Values from 1 - 31
int m = month();  // Values from 1 - 12
int y = year();   // 2003, 2004, 2005, etc.

int defaultColor = 125;

boolean buttonA_clicked = true;
boolean buttonB_clicked = true;
boolean buttonC_clicked = true;
boolean buttonD_clicked = true;
boolean buttonE_clicked = true;
boolean buttonF_clicked = true;
boolean buttonG_clicked = true;
boolean buttonH_clicked = true;
boolean buttonI_clicked = true;
boolean buttonJ_clicked = true;

int valueA = 0;
int valueB = 1;
int valueC = 2;
int valueD = 3;
int valueE = 4;
int valueF = 5;
int valueG = 6;
int valueH = 7;
int valueI = 8;
int valueJ = 9;

void setup() {
  fullScreen();

  background(125, 125, 125);

  String StepMotor = "Hello";// Serial.list()[0];

  println(StepMotor);

  //myStepMotor = new Serial(this, StepMotor, 9600);

  fill(0, 0, 0);
  text("(ESC) PRESS TO EXIT", 1790, 20);

  fill(0, 0, 0);
  text("/", 1867, 1070);

  fill(0, 0, 0);
  text("/", 1878, 1070);

  String s = String.valueOf(d);
  text(s, 1852, 1070);
  s = String.valueOf(m);
  text(s, 1871, 1070); 
  s = String.valueOf(y);
  text(s, 1883, 1070);
}


void draw() {


  if (buttonA_clicked) {
    fill(buttonA_colorR, buttonA_colorG, buttonA_colorB);
  } else if (buttonB_clicked) {
    fill(buttonB_colorR, buttonB_colorG, buttonB_colorB);
  } else if (buttonC_clicked) {
    fill(buttonC_colorR, buttonC_colorG, buttonC_colorB);
  } else if (buttonD_clicked) {
    fill(buttonD_colorR, buttonD_colorG, buttonD_colorB);
  } else if (buttonE_clicked) {
    fill(buttonE_colorR, buttonE_colorG, buttonE_colorB);
  } else if (buttonF_clicked) {
    fill(buttonF_colorR, buttonF_colorG, buttonF_colorB);
  } else if (buttonG_clicked) {
    fill(buttonG_colorR, buttonG_colorG, buttonG_colorB);
  } else if (buttonH_clicked) {
    fill(buttonH_colorR, buttonH_colorG, buttonH_colorB);
  } else if (buttonI_clicked) {
    fill(buttonI_colorR, buttonI_colorG, buttonI_colorB);
  } else if (buttonJ_clicked) {
    fill(buttonJ_colorR, buttonJ_colorG, buttonJ_colorB);
  }

  fill(buttonA_colorR, buttonA_colorG, buttonA_colorB);
  rect(buttonA_x, buttonA_y, buttonA_width, buttonA_height);

  fill(buttonB_colorR, buttonB_colorG, buttonB_colorB);
  rect(buttonB_x, buttonB_y, buttonB_width, buttonB_height);

  fill(buttonC_colorR, buttonC_colorG, buttonC_colorB);
  rect(buttonC_x, buttonC_y, buttonC_width, buttonC_height);

  fill(buttonD_colorR, buttonD_colorG, buttonD_colorB);
  rect(buttonD_x, buttonD_y, buttonD_width, buttonD_height);

  fill(buttonE_colorR, buttonE_colorG, buttonE_colorB);
  rect(buttonE_x, buttonE_y, buttonE_width, buttonE_height);

  fill(buttonF_colorR, buttonF_colorG, buttonF_colorB);
  rect(buttonF_x, buttonF_y, buttonF_width, buttonF_height);

  fill(buttonG_colorR, buttonG_colorG, buttonG_colorB);
  rect(buttonG_x, buttonG_y, buttonG_width, buttonG_height);

  fill(buttonH_colorR, buttonH_colorG, buttonH_colorB);
  rect(buttonH_x, buttonH_y, buttonH_width, buttonH_height);

  fill(buttonI_colorR, buttonI_colorG, buttonI_colorB);
  rect(buttonI_x, buttonI_y, buttonI_width, buttonI_height);

  fill(buttonJ_colorR, buttonJ_colorG, buttonJ_colorB);
  rect(buttonJ_x, buttonJ_y, buttonJ_width, buttonJ_height);

  textAlign(CENTER, CENTER); 

  fill(255);
  text("UP", 
    buttonA_x+buttonA_width/2, buttonA_y+buttonA_height/2);

  fill(255); 
  text("DOWN", 
    buttonB_x+buttonB_width/2, buttonB_y+buttonB_height/2);

  fill(255);
  text("STOP", 
    buttonC_x+buttonC_width/2, buttonC_y+buttonC_height/2);

  fill(255);
  text("TURN ON", 
    buttonD_x+buttonC_width/2, buttonD_y+buttonD_height/2);

  fill(255);
  text("TURN OFF", 
    buttonE_x+buttonC_width/2, buttonE_y+buttonD_height/2);

  fill(255);
  text("HOME", 
    buttonF_x+buttonF_width/2, buttonF_y+buttonF_height/2);

  fill(255);
  text("↑50", 
    buttonG_x+buttonG_width/2, buttonG_y+buttonG_height/2);

  fill(255);
  text("↓50", 
    buttonH_x+buttonH_width/2, buttonH_y+buttonH_height/2);

  fill(255);
  text("ACTIVE", 
    buttonI_x+buttonI_width/2, buttonI_y+buttonI_height/2);

  fill(255);
  text("INACTIVE", 
    buttonJ_x+buttonJ_width/2, buttonJ_y+buttonJ_height/2);


  if (fanIsActive)
    fill(2, 255, 0);
  else 
  fill(255, 0, 2);
  ellipse(1870, 889, 15, 15);

  if (fanIsActive)
    fill(255, 0, 0);
  else 
  fill(0, 245, 0);  
  ellipse(1870, 974, 15, 15);
}

void mouseClicked() {
  // mouseX = x of mouse click position
  // mouseY = y of mouse click position

  if (mouseX >= buttonA_x && mouseX <= buttonA_x + buttonA_width && 
    mouseY >= buttonA_y && mouseY <= buttonA_y + buttonA_height) {
    buttonA_clicked = true;

    myStepMotor.write("1");
    print("1");
  } else {
    buttonA_clicked = false;
  }

  if (mouseX >= buttonB_x && mouseX <= buttonB_x + buttonB_width && 
    mouseY >= buttonB_y && mouseY <= buttonB_y + buttonB_height) {
    buttonB_clicked = true;

    myStepMotor.write("0");
    print("0");
  } else {
    buttonB_clicked = false;
  }

  if (mouseX >= buttonC_x && mouseX <= buttonC_x + buttonC_width && 
    mouseY >= buttonC_y && mouseY <= buttonC_y + buttonC_height) {
    buttonC_clicked = true;

    myStepMotor.write("2");
    print("2");
  } else {
    buttonC_clicked = false;
  }

  if (mouseX >= buttonD_x && mouseX <= buttonD_x + buttonD_width && 
    mouseY >= buttonD_y && mouseY <= buttonD_y + buttonD_height) {
    buttonD_clicked = true;

    myStepMotor.write("3");
    print("3");
  } else {
    buttonD_clicked = false;
  }

  if (mouseX >= buttonE_x && mouseX <= buttonE_x + buttonE_width && 
    mouseY >= buttonE_y && mouseY <= buttonE_y + buttonE_height) {
    buttonE_clicked = true;

    myStepMotor.write("4");
    print("4");
  } else {
    buttonE_clicked = false;
  }

  if (mouseX >= buttonF_x && mouseX <= buttonF_x + buttonF_width && 
    mouseY >= buttonF_y && mouseY <= buttonF_y + buttonF_height) {
    buttonF_clicked = true;

    myStepMotor.write("5");
    print("5");
  } else {
    buttonF_clicked = false;
  }

  if (mouseX >= buttonG_x && mouseX <= buttonG_x + buttonG_width && 
    mouseY >= buttonG_y && mouseY <= buttonG_y + buttonG_height) {
    buttonG_clicked = true;
    myStepMotor.write("6");
    print("6");
  } else {
    buttonG_clicked = false;
  }

  if (mouseX >= buttonH_x && mouseX <= buttonH_x + buttonH_width && 
    mouseY >= buttonH_y && mouseY <= buttonH_y + buttonH_height) {
    buttonH_clicked = true;
    myStepMotor.write("7");
    print("7");
  } else {
    buttonH_clicked = false;
  }  

  if (mouseX >= buttonI_x && mouseX <= buttonI_x + buttonI_width && 
    mouseY >= buttonI_y && mouseY <= buttonI_y + buttonI_height) {
    buttonI_clicked = true;
    fill(0, 255, 0);
    ellipse(1870, 889, 15, 15);
    // myStepMotor.write("8");
    fanIsActive=true; 
    print("8");
  } else {
    buttonI_clicked = false;
  }
  if (mouseX >= buttonJ_x && mouseX <= buttonJ_x + buttonJ_width && 
    mouseY >= buttonJ_y && mouseY <= buttonJ_y + buttonJ_height) {
    buttonJ_clicked = true;
    fill(0, 255, 0);
    ellipse(1870, 974, 15, 15);
    fanIsActive=false; 
    // myStepMotor.write("9");
  } else {
    buttonJ_clicked = false;
  }
}
//

Thankssssss :call_me_hand: You are awesomeee