Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Detect Line Code
- package ALFBot;
- import lejos.hardware.port.SensorPort;
- import lejos.hardware.sensor.EV3ColorSensor;
- import lejos.robotics.subsumption.Behavior;
- public class DetectLine implements Behavior
- {
- private EV3ColorSensor colour = new EV3ColorSensor(SensorPort.S1);
- float avLight = 0.3f;
- @Override
- public boolean takeControl()
- {
- return false;
- }
- @Override
- public void action()
- {
- colour.fetchSample(Driver.samples, 0);
- if (Driver.samples[0] < avLight)
- {
- Driver.isLine = true;
- }
- }
- @Override
- public void suppress()
- {
- Driver.isLine = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement