Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <Servo.h>
  2. Servo myservo;
  3. int a = 90;
  4. char val;
  5.  
  6. void setup() {
  7. Serial.begin(9600); // Start serial communication at 9600 bps
  8. myservo.attach(3);
  9. myservo.write(a);
  10. }
  11.  
  12.  
  13. void loop() {
  14. while (Serial.available()) { // If data is available to read,
  15. val = Serial.read(); // read it and store it in val
  16. }
  17. if (val == 'H') {
  18. a = a - 1;
  19. if(a < 0 )a=0;
  20. myservo.write(a);
  21. } if(val == 'L'){
  22. a = a + 1;
  23. if(a > 180)a = 180;
  24. myservo.write(a);
  25. }
  26.  
  27. delay(100);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement