esha492

SERVITO FINAL

Oct 4th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include <Servo.h>
  2. Servo servito;
  3. const int ServoPin=5;
  4. const int PotPin=A0;
  5. int PotVal;
  6. int angle;
  7. void setup ();
  8.  
  9.  
  10. void setup() {
  11. pinMode (PotPin, INPUT);
  12. servito.attach (ServoPin);
  13. Serial.begin (9600);
  14.  
  15. }
  16.  
  17. void loop() {
  18.  
  19. PotVal= analogRead (PotPin) ;
  20. angle= map(PotVal, 0, 1023, 0, 180);
  21. angle= constrain(angle, 0, 180);
  22. servito.write(angle);
  23. delay (5);
  24.  
  25.  
  26. }
Add Comment
Please, Sign In to add comment