CODE :-
#include <Servo.h>
int IndexFinger=3;
int MidFinger=5;
int RingFinger=6;
int LitFinger=9;
int Thumb=10;
String Position;
Servo IndexFingerServo;
Servo MidFingerServo;
Servo RingFingerServo;
Servo LitFingerServo;
Servo ThumbServo;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
IndexFingerServo.attach(IndexFinger);
MidFingerServo.attach(MidFinger);
RingFingerServo.attach(RingFinger);
LitFingerServo.attach(LitFinger);
ThumbServo.attach(Thumb);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("What Your Position");
while (Serial.available()==0){
}
Position=Serial.readString();
if (Position=="open") {
ThumbServo.write(160);
delay(200);
IndexFingerServo.write(180);
delay(200);
MidFingerServo.write(180);
delay(200);
RingFingerServo.write(180);
delay(200);
LitFingerServo.write(180);
delay(200);
Serial.println("open");
}
if (Position=="close") {
IndexFingerServo.write(70);
delay(200);
MidFingerServo.write(70);
delay(200);
RingFingerServo.write(70);
delay(200);
LitFingerServo.write(70);
delay(200);
ThumbServo.write(30);
delay(200);
Serial.println("close");
}
}
0 Comments