fork download
  1. #include <Servo.h>
  2. Servo myservo1;
  3. Servo myservo2;
  4. int joyPin1 = 0; // davant 3 - darrera 1023
  5. int joyPin2 = 1; //esquerra 1023 - dreta 0
  6.  
  7. void setup() {
  8. Serial.begin(9600);
  9. myservo1.attach(9);
  10. myservo2.attach(10);
  11. pinMode(joyPin1, INPUT);
  12. pinMode(joyPin2, INPUT);
  13. }
  14.  
  15. void loop() {
  16. int davant_darrera = analogRead(joyPin1);
  17. int esquerra_dreta = analogRead(joyPin2);
  18. Serial.println(davant_darrera);
  19. if (davant_darrera<200) //davant
  20. {
  21. Serial.println("Endevant...");
  22. myservo1.write(0);
  23. myservo2.write(180);
  24. }
  25. else if (davant_darrera>800)//darrera
  26. {Serial.println("Darrera...");
  27. myservo1.write(180);
  28. myservo2.write(0);
  29. }
  30. else if (esquerra_dreta<200) //dreta
  31. {
  32. myservo1.write(0);
  33. myservo2.write(0);
  34. }
  35. else if (esquerra_dreta>800)//esquerra
  36. {
  37. myservo1.write(180);
  38. myservo2.write(180);
  39. }
  40. else
  41. {
  42. Serial.println("Aturat...");
  43. myservo1.write(90);
  44. myservo2.write(90);
  45. }
  46. delay(100);
  47. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:19: fatal error: Servo.h: No such file or directory
compilation terminated.
stdout
Standard output is empty