Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <Servo.h>
  2. Servo servo1;
  3. Servo servo2;
  4.  
  5. int BlackLine = 0;
  6. float BlackTotal;
  7.  
  8. void setup() {
  9.  
  10. servo1.attach(6);
  11. servo2.attach(7);
  12. Serial.begin(115200);
  13. }
  14.  
  15. void loop() {
  16.  
  17. analogReference(EXTERNAL);
  18.  
  19. BlackLine = analogRead(1);
  20.  
  21. if (BlackLine > 792)
  22. {
  23. servo1.writeMicroseconds(1400);
  24. servo2.writeMicroseconds(1500);
  25. delay(100);
  26. servo1.writeMicroseconds(1500);
  27. delay(100);
  28. BlackTotal = BlackTotal + 1;
  29.  
  30. }
  31. else
  32. {
  33. servo1.writeMicroseconds(1500);
  34. servo2.writeMicroseconds(1600);
  35. delay(100);
  36. servo2.writeMicroseconds(1500);
  37. delay(100);
  38. }
  39.  
  40. Serial.print(BlackLine);
  41. Serial.print(",");
  42. Serial.print(BlackTotal);
  43. Serial.println(" ");
  44. delay(100);
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement