서보모터와 스위치를 이용해 로봇팔을 만들고 싶은데요, motor5라는 오른팔을 이용해 180도까지 움직였다가 다시 반대 방향으로 움직이면서 팔에 달려있는 스위치가 눌러진다면 특정 동작을 수행하고 안눌러지면 motor4를 다시 구동시키고 싶은데 이 것을 어떻게 소스를 짜야할지 모르겠습니다.
--------------------------------------------------------------------
Servo motor3;
Servo motor4;
Servo motor5;
const int inputPin1 = 6;
const int inputPin2 = 7;
void setup() {
Serial.begin(9600);
motor3.attach(3);
motor4.attach(4);
motor5.attach(5);
motor3.write(90);
motor4.write(90);
motor5.write(90);
pinMode(inputPin1, INPUT_PULLUP);
pinMode(inputPin2, INPUT_PULLUP);
}
void loop() {
motor5.write(180);
delay(500);
while()
}