Tzouraguy

RoboLab 4_3 full code

Nov 20th, 2020 (edited)
1,245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Servo.h>
  2.  
  3. Servo my_servo;
  4. int max, min, tick;
  5.  
  6. void setup()
  7. {
  8.   my_servo.attach(6);//Assign pin to component
  9.   max=1000;
  10.   min=50;
  11. }
  12.  
  13. void loop()
  14. {
  15.   tick = analogRead(A0);
  16.   my_servo.write(map(tick,min,max,180,0));
  17.   if(tick<min)min=tick; //Lower knob bound recalibration
  18.   if(tick>max)max=tick; //Upper knob bound recalibration
  19. }
Add Comment
Please, Sign In to add comment