Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <dmoto.h>
  2. dmoto Light;
  3. float ldrRemove =0;
  4. void setup() {
  5. Serial.begin(9600);
  6. Light.pinSet();
  7. Light.Stop();
  8. }
  9.  
  10. void loop() {
  11. ldrRemove = abs(Light.LdrRightValue() - Light.LdrLeftValue());
  12. Serial.print(Light.LdrRightValue());
  13. Serial.print(" ");
  14. Serial.print(Light.LdrLeftValue());
  15. Serial.print(" ");
  16. Serial.println(ldrRemove);
  17. delay(30);
  18. if (Light.LdrRightValue() > Light.LdrLeftValue() && ldrRemove > 80)
  19. {
  20. Light.Left(150,70);
  21.  
  22. }
  23. if (Light.LdrRightValue() < Light.LdrLeftValue() && ldrRemove > 80)
  24. {
  25. Light.Right(70,150);
  26.  
  27. }
  28. if (ldrRemove < 80)
  29. {
  30. Light.Forward(150);
  31.  
  32. }
  33.  
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement