Advertisement
Guest User

ESCTEST

a guest
Aug 8th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <Servo.h>
  2.  
  3. Servo myMotor;
  4. int potpin = 0; // analog pin used to connect the potentiometer
  5. int val; // variable to read the value from the analog pin
  6.  
  7. void setup()
  8. {
  9. myMotor.attach(8);
  10. Serial.begin(9600);
  11. }
  12.  
  13. void loop()
  14. {
  15. val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
  16. val = map(val, 0, 1023, 0, 169); // scale it to use it with the servo (value between 0 and 180)
  17. myMotor.write(val);
  18. Serial.println(val);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement