Advertisement
AnindyaBiswas

Servo

Feb 27th, 2023
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<Servo.h>
  2.  
  3. Servo the_servo;
  4.  
  5. int pos = 0;
  6.  
  7. void setup() {
  8.   // put your setup code here, to run once:
  9.   the_servo.attach(9);
  10.   pinMode(11, OUTPUT);
  11. }
  12.  
  13. void loop() {
  14.   // put your main code here, to run repeatedly:
  15.  
  16.  
  17.   delay(100);
  18.   for(int i=0; i<=180; i++)
  19.   {
  20.     the_servo.write(i);
  21.     delay(100);
  22.   }
  23.   delay(100);
  24.     for(int i=180; i>=0; i--)
  25.   {
  26.     digitalWrite(11, 200);
  27.     the_servo.write(i);
  28.     delay(10);
  29.   }
  30.   digitalWrite(11,0);
  31.  
  32.  
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement