Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. int ana=0;
  2. int P=0;
  3. int M=0;
  4. int angle=0;
  5. int et=0;
  6.  
  7.  
  8. #include <Servo.h>
  9.  
  10. Servo esc ;
  11.  
  12. void setup()
  13. {pinMode(22,INPUT); //22 : bouton poussoir pour le plus
  14. pinMode(23,INPUT); //23 : bouton poussoir pour le moins
  15. esc.attach(8);
  16. Serial.begin(9600);
  17. }
  18.  
  19.  
  20. void loop()
  21. { P = digitalRead(22); //P->plus : lit état bouton plus (pin 22)
  22. M=digitalRead(23);
  23. while(P==HIGH)
  24. {ana=ana+1;
  25. delay(500);
  26. P = digitalRead(22);
  27. }
  28.  
  29. Serial.print("ana");
  30. Serial.println(ana);
  31.  
  32.  
  33. while(M==HIGH)
  34. {ana=ana-1;
  35. delay(500);
  36. M=digitalRead(23);
  37. }
  38.  
  39. angle=map(ana,0,90,1500,2000);
  40. esc.writeMicroseconds(angle);
  41. delay(100);
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement