timor2542

[4 DOF Robot Arm Keyestudio][Lab 03][i-Duino UNO R3B] Gripper Test

Aug 2nd, 2021
934
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Servo.h>
  2. Servo myservo1;
  3. Servo myservo2;
  4. Servo myservo3;
  5. Servo myservo4;
  6. int pos1 = 90, pos2 = 90, pos3 = 100, pos4 = 0;
  7. void setup() {
  8.   checkSW();
  9.   myservo1.attach(A1);
  10.   myservo2.attach(A0);
  11.   myservo3.attach(6);
  12.   myservo4.attach(9);
  13.  
  14.   myservo1.write(pos1);
  15.   myservo2.write(pos2);
  16.   myservo3.write(pos3);
  17.   myservo4.write(pos4);
  18.   delay(3000);
  19. }
  20.  
  21. void loop() {
  22.  
  23.   for(pos4;pos4<100;pos4++)
  24.   {
  25.     myservo4.write(pos4);
  26.     delay(5);
  27.   }
  28.   delay(3000);
  29.   for(pos3;pos3>30;pos3--)
  30.   {
  31.     myservo3.write(pos3);
  32.     delay(5);
  33.   }
  34.   delay(3000);
  35.   for(pos4;pos4>0;pos4--)
  36.   {
  37.     myservo4.write(pos4);
  38.     delay(5);
  39.   }
  40.   delay(3000);
  41.   for(pos3;pos3<100;pos3++)
  42.   {
  43.     myservo3.write(pos3);
  44.     delay(5);
  45.   }
  46.   delay(3000);
  47.   for(pos2;pos2>30;pos2--)
  48.   {
  49.     myservo2.write(pos2);
  50.     delay(5);
  51.   }
  52.   delay(3000);
  53.   for(pos2;pos2<90;pos2++)
  54.   {
  55.     myservo2.write(pos2);
  56.     delay(5);
  57.   }
  58.   delay(3000);
  59.   for(pos3;pos3>30;pos3--)
  60.   {
  61.     myservo3.write(pos3);
  62.     delay(5);
  63.   }
  64.   delay(3000);
  65.   for(pos4;pos4<100;pos4++)
  66.   {
  67.     myservo4.write(pos4);
  68.     delay(5);
  69.   }
  70.   delay(3000);
  71.   for(pos3;pos3<100;pos3++)
  72.   {
  73.     myservo3.write(pos3);
  74.     delay(5);
  75.   }
  76.   delay(3000);
  77.   for(pos4;pos4>0;pos4--)
  78.   {
  79.     myservo4.write(pos4);
  80.     delay(5);
  81.   }
  82.   delay(3000);
  83. }
  84. void checkSW()
  85. {
  86.   pinMode(7, INPUT);
  87.   while(!digitalRead(7)){
  88.  
  89.   }
  90.  
  91. }
  92.  
RAW Paste Data