Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include <Servo.h>
  2.  
  3. Servo arm;
  4.  
  5. int ch5;
  6. int val;
  7. void setup() {
  8. // put your setup code here, to run once:
  9. arm.attach(9);
  10. pinMode(10, INPUT);
  11. Serial.begin(9600);
  12.  
  13. }
  14.  
  15. void loop() {
  16. // put your main code here, to run repeatedly:
  17. ch5 = pulseIn(10, HIGH, 25000);
  18. val = map(ch5, 984, 1968, 0, 180);
  19. val = constrain(val, 0, 180);
  20.  
  21. arm.write(val);
  22. delay(15);
  23.  
  24. Serial.print("Channel 5:");
  25.  
  26. Serial.println(val);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement