second arm

This commit is contained in:
adrian
2026-01-28 21:31:56 +01:00
parent fd09e270ec
commit bbaa1da025
2 changed files with 33 additions and 2 deletions

BIN
arm-mitt.FCStd Normal file

Binary file not shown.

View File

@ -2,16 +2,25 @@
Servo ServoBase; Servo ServoBase;
Servo ServoArmOne; Servo ServoArmOne;
Servo ServoArmTwo;
const int SW_pin = 10; const int SW_pin = 10;
const int X_pin = A1; const int X_pin = A1;
const int Y_pin = A0; const int Y_pin = A0;
const int podpin = A3;
const int leftButton = 7;
const int rightButton = 8;
void setup () { void setup () {
ServoBase.attach(13); ServoBase.attach(13);
ServoArmOne.attach(12); ServoArmOne.attach(12);
ServoArmTwo.attach(9);
Serial.begin(9600); Serial.begin(9600);
pinMode(SW_pin, INPUT); pinMode(SW_pin, INPUT);
digitalWrite(SW_pin, HIGH); digitalWrite(SW_pin, HIGH);
pinMode(leftButton, INPUT_PULLUP);
pinMode(rightButton, INPUT_PULLUP);
} }
void loop() { void loop() {
@ -19,6 +28,7 @@ void loop() {
bool SW = digitalRead(SW_pin); bool SW = digitalRead(SW_pin);
if (!SW) { if (!SW) {
ServoBase.write(90); ServoBase.write(90);
ServoArmOne.write(90);
} }
@ -28,6 +38,7 @@ int Y_State = analogRead(Y_pin);
int currentYState = ServoBase.read(); int currentYState = ServoBase.read();
if (Y_State > 524) { if (Y_State > 524) {
int newYState = currentYState + 1; int newYState = currentYState + 1;
ServoBase.write(newYState); ServoBase.write(newYState);
@ -48,6 +59,7 @@ int currentXState = ServoArmOne.read();
int newXState = currentXState + 1; int newXState = currentXState + 1;
ServoArmOne.write(newXState); ServoArmOne.write(newXState);
delay(15); delay(15);
}else if (X_State < 502) { }else if (X_State < 502) {
int newXState = currentXState - 1; int newXState = currentXState - 1;
ServoArmOne.write(newXState); 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);
}
}