Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Dec 6th, 2018 62 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top