timor2542

[4 DOF Robot Arm Keyestudio][Lab 02][i-Duino UNO R3B] Each +/- 90 Degree Base Servo Speed Control

Aug 2nd, 2021
872
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Servo.h>
  2. Servo myservo1;
  3. int pos1 = 90;
  4. void setup() {
  5.   checkSW();
  6.   myservo1.attach(A1);
  7.   delay(3000);
  8. }
  9.  
  10. void loop() {
  11.  
  12.   for(pos1;pos1>0;pos1--)
  13.   {
  14.     myservo1.write(pos1);
  15.     delay(10);
  16.   }
  17.   delay(3000);
  18.   for(pos1;pos1<90;pos1++)
  19.   {
  20.     myservo1.write(pos1);
  21.     delay(10);
  22.   }
  23.   delay(3000);
  24.   for(pos1;pos1<180;pos1++)
  25.   {
  26.     myservo1.write(pos1);
  27.     delay(10);
  28.   }
  29.   delay(3000);
  30.   for(pos1;pos1>90;pos1--)
  31.   {
  32.     myservo1.write(pos1);
  33.     delay(10);
  34.   }
  35.   delay(3000);
  36. }
  37. void checkSW()
  38. {
  39.   pinMode(7, INPUT);
  40.   while(!digitalRead(7)){
  41.  
  42.   }
  43.  
  44. }
  45.  
RAW Paste Data