diff --git a/arm-mitt.FCStd b/arm-mitt.FCStd new file mode 100644 index 0000000..e3e56c4 Binary files /dev/null and b/arm-mitt.FCStd differ diff --git a/roboterarm/roboterarm.ino b/roboterarm/roboterarm.ino index 0e3f808..6a718aa 100644 --- a/roboterarm/roboterarm.ino +++ b/roboterarm/roboterarm.ino @@ -2,16 +2,25 @@ Servo ServoBase; Servo ServoArmOne; +Servo ServoArmTwo; const int SW_pin = 10; const int X_pin = A1; const int Y_pin = A0; +const int podpin = A3; +const int leftButton = 7; +const int rightButton = 8; void setup () { ServoBase.attach(13); ServoArmOne.attach(12); + ServoArmTwo.attach(9); Serial.begin(9600); pinMode(SW_pin, INPUT); digitalWrite(SW_pin, HIGH); + pinMode(leftButton, INPUT_PULLUP); + pinMode(rightButton, INPUT_PULLUP); + + } void loop() { @@ -19,6 +28,7 @@ void loop() { bool SW = digitalRead(SW_pin); if (!SW) { ServoBase.write(90); + ServoArmOne.write(90); } @@ -28,6 +38,7 @@ int Y_State = analogRead(Y_pin); int currentYState = ServoBase.read(); + if (Y_State > 524) { int newYState = currentYState + 1; ServoBase.write(newYState); @@ -48,6 +59,7 @@ int currentXState = ServoArmOne.read(); int newXState = currentXState + 1; ServoArmOne.write(newXState); delay(15); + }else if (X_State < 502) { int newXState = currentXState - 1; ServoArmOne.write(newXState); @@ -55,8 +67,27 @@ int currentXState = ServoArmOne.read(); } +//armTwo movement + +int currentStateLeftButton = digitalRead(leftButton); +int currentStateRightButton = digitalRead(rightButton); +int currentStateArmTwo = ServoArmTwo.read(); +Serial.print("button: "); +Serial.print(leftButton); +Serial.print(rightButton); +Serial.print("\n"); + +while (leftButton == HIGH) { + + int newStateArmTwo = currentStateArmTwo + 1; + ServoArmTwo.write(newStateArmTwo); + delay(15); } +while (rightButton == HIGH) { + int newStateArmTwo = currentStateArmTwo - 1; + ServoArmTwo.write(newStateArmTwo); + delay(15); +} - - +}