Programming help

I am working on project, where want to turn On/Off two pins of Aruduino Uno through command from Processing software.I attached the code, wrote for processing software. There are 4 buttons (2 each for two pins of Arduino). My problem is that I am struggling to write Arduino code, which will communicate with the processing code. For example, if I click On/Off button, one pin will go HIGH/LOW. I wrote code for Arduino with two ports. No idea, whether this is the right approach or not. I would appreciate your help.

Regards,

TwoPortsArduino.ino (1.44 KB)

sketch_4Buttons.pde (3.92 KB)

I would suggest you would first learn how to use the forum here.
So we don't have to download code. Thanks!

Coming to your project, 2 ports is not the way you would want to go. And what do you mean by 'command'?
Why don't you keep 1 button for each pin for making it HIGH/LOW?

Good Morning! Thank you very much for your response. I pasted the codes below. My idea of making two buttons for each Arduino pin so that clicking one button will make the pin HIGH and the clicking other will make that pin LOW. Command I meant clicking the buttons from Processing Software. I don't have any problem making only one Arduino pin HIGH/LOW from Processing Software. Now I want two pins to be HIGH/LOW independently. If you think it can be done in simpler way, please let me know. I would appreciate very much.

#include "SoftwareSerial.h"
char val1; // variable to receive data from the serial port 1
char val2; // variable to receive data from the serail port 2
int ledpin = 9; // Arduino LED pin 9 
int pin = 11;  // Arduino LED pin 11

// software serial #1: RX = digital pin 0, TX = digital pin 1
SoftwareSerial portOne(0, 1);

// software serial #2: RX = digital pin 2, TX = digital pin 3
SoftwareSerial portTwo(2, 3);

void setup() {
   pinMode(ledpin, OUTPUT); // pin 9 (on-board LED) as OUTPUT
   pinMode(pin, OUTPUT);
   Serial.begin(9600); // start serial communication at 9600bps
   portOne.begin(9600);
   portTwo.begin(9600);
}
 
void loop() {
   
   portOne.listen();
   if( portOne.available() ) // if data is available to read
   {
      val1 = Serial.read(); // read it and store it in 'val1'
   }
   if( val1 == 'H' ) // if 'H' was received
   {
      digitalWrite(ledpin, LOW); // turn ON the pin 9
      
    } 
    else 
    {
      digitalWrite(ledpin, HIGH); // otherwise turn it OFF
      
    }

portTwo.listen();
   if( portTwo.available() ) // if data is available to read
   {
      val2 = Serial.read(); // read it and store it in 'val2'
   }
   if( val2 == 'H' ) // if 'H' was received
   {
      digitalWrite(pin, LOW); // turn ON the pin 11
      
    } 
    else 
    {
      digitalWrite(pin, HIGH); // otherwise turn it OFF
      
    }
    
   delay(100); // wait 100ms for next reading
}
import processing.serial.*;// importing serial library
Serial port;   // Naming serial port
float buttonA_x = 20;
int buttonA_y = 35;
int buttonA_width = 75;
int buttonA_height = 75;
int buttonA_colorR = 0x25;
int buttonA_colorG = 0x25;
int buttonA_colorB = 0x25;

float buttonB_x = 20;
int buttonB_y = 130;
int buttonB_width = 75;
int buttonB_height = 75;
int buttonB_colorR = 0x25;
int buttonB_colorG = 0x25;
int buttonB_colorB = 0x25;

float buttonC_x = 175;
int buttonC_y = 35;
int buttonC_width = 75;
int buttonC_height = 75;
int buttonC_colorR = 0x25;
int buttonC_colorG = 0x25;
int buttonC_colorB = 0x25;

float buttonD_x = 175;
int buttonD_y = 130;
int buttonD_width = 75;
int buttonD_height = 75;
int buttonD_colorR = 0x25;
int buttonD_colorG = 0x25;
int buttonD_colorB = 0x25;

int defaultColor = 125;

boolean buttonA_clicked = false;
boolean buttonB_clicked = false;
boolean buttonC_clicked = false;
boolean buttonD_clicked = false;

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

void setup() {
  size(335, 230);
  background(125);
  port = new Serial(this, "Com6", 9600);  //setting com port and baud rate
}

void draw() {

  background(125);

  if (buttonA_clicked) {
        port.write('H');
  } else if (buttonB_clicked) {
        port.write('L');
     
  }
  if (buttonC_clicked) {
        port.write('H');
  } else if (buttonC_clicked) {
        port.write('L');
  }

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

  fill(buttonB_colorR, buttonB_colorG, buttonA_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(255); 

  fill(0, 0, 0);
  text("Falcon Pairing", 18, 20);
  fill(0, 0, 0);
  text("Falcon Cycling", 180, 20);

  //fill(0, 0, 0);
  text("/", 280, 220);

  //fill(0, 0, 0);
  text("/", 296, 220);

  String s = String.valueOf(d);
  text(s, 282, 220);
  s = String.valueOf(m);
  text(s, 272, 220); 
  s = String.valueOf(y);
  text(s, 298, 220);

  textAlign(CENTER, CENTER); 
  fill(255);
  
  text("Start", 
    buttonA_x+buttonA_width/2, buttonA_y+buttonA_height/2);

  fill(255); 
  text("Stop", 
    buttonB_x+buttonB_width/2, buttonB_y+buttonB_height/2);
    
    text("On", 
    buttonC_x+buttonC_width/2, buttonC_y+buttonC_height/2);

  fill(255); 
  text("Off", 
    buttonD_x+buttonD_width/2, buttonD_y+buttonD_height/2);

  // reset 
  textAlign(LEFT);
}// func 

/* The mouseClicked() function is called once after a mouse button 
 * has been pressed and then released.
 */
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;
  } else {
    buttonA_clicked = false;
  }

  if (mouseX >= buttonB_x && mouseX <= buttonB_x + buttonB_width && 
    mouseY >= buttonB_y && mouseY <= buttonB_y + buttonB_height) {
    buttonB_clicked = true;
  } else {
    buttonB_clicked = false;
  }
  
  if (mouseX >= buttonC_x && mouseX <= buttonC_x + buttonC_width && 
    mouseY >= buttonC_y && mouseY <= buttonC_y + buttonC_height) {
    buttonC_clicked = true;
  } else {
    buttonC_clicked = false;
  }

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

Why a different data type for x and y?

float buttonB_x = 20;
int buttonB_y = 130;

You are right aarg. It should be same. I just noticed it. Thank you very much!

Anyway, do you have any suggestion how can I activate two pins independently by clicking the button in Processing Software? Would appreciate your help

I would appreciate any of your help. I am stuck on my project.

Regards,