Advertisement
Guest User

Untitled

a guest
Dec 6th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. // Detect Line Code
  2.  
  3. package ALFBot;
  4.  
  5. import lejos.hardware.port.SensorPort;
  6. import lejos.hardware.sensor.EV3ColorSensor;
  7. import lejos.robotics.subsumption.Behavior;
  8.  
  9. public class DetectLine implements Behavior
  10. {
  11. private EV3ColorSensor colour = new EV3ColorSensor(SensorPort.S1);
  12. float avLight = 0.3f;
  13.  
  14. @Override
  15. public boolean takeControl()
  16. {
  17. return false;
  18. }
  19.  
  20. @Override
  21. public void action()
  22. {
  23. colour.fetchSample(Driver.samples, 0);
  24.  
  25. if (Driver.samples[0] < avLight)
  26. {
  27. Driver.isLine = true;
  28. }
  29. }
  30.  
  31. @Override
  32. public void suppress()
  33. {
  34. Driver.isLine = false;
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement