How to make 2 pins do the same thing?

I want to make 2 touch sensors do the same thing which is to move the servo but i dont know how can anyone help?

here is the code:

#include <Servo.h>

const int TOUCH_SENSOR_PIN   = 6;   // Arduino pin connected to touch sensor's pin
const int SERVO_PIN          = 9;   // Arduino pin connected to servo motor's pin

Servo servo; // create servo object to control a servo

// variables will change:
int angle = 141;           // the current angle of servo motor
int lastTouchState;      // the previous state of touch sensor
int currentTouchState;   // the current state of touch sensor


void setup() {
  Serial.begin(9600);      // initialize serial
  pinMode(TOUCH_SENSOR_PIN, INPUT);
  servo.attach(SERVO_PIN);       // attaches the servo on pin 9 to the servo object

  servo.write(angle);
  currentTouchState = digitalRead(TOUCH_SENSOR_PIN);
}

void loop() {
  lastTouchState    = currentTouchState;  // save the last state
  currentTouchState = digitalRead(TOUCH_SENSOR_PIN);  //read new state 

  if(lastTouchState == LOW && currentTouchState == HIGH) {

    // change angle of servo motor
    if(angle == 141)
      angle = 156;
    else
    if(angle == 156)
      angle = 141;


    // control servo motor arccoding to the angle
    servo.write(angle);
    

      }
  }

Because of its layout some of your code has had code tags added to it by the forum software

Please follow the advice given in the link below and post **all **of it in code tags

where is the second touch sensor?

I didnt put the second touch sensor because i dont know how to make them both work
so this is the only code that works
the one with 1 touch sensor
but i need help from someone to put the second sensor on pin 7
the second touch sensor should be called TOUCH_SENSOR_PIN2

Have them both call the same function.

void beenTouched();

-jim lee

can you put it in the code? i dont know how to

Make a second set of variables for the second switch.  Maybe call them switchAxxx and switchBxxx to differentiate one from the other.  So, two pinModes(), etc.

When you can sense both switches combine their states with the logical OR ( || ), aka pipe symbol.

i solved the problem but tnx