Created
October 16, 2014 20:23
-
-
Save jeffschulthies/efd2f77933787032b981 to your computer and use it in GitHub Desktop.
Line Clockwise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*import lejos.nxt.*; | |
public class Line { | |
public static void main (String[] args) throws Exception { | |
LightSensor light = new LightSensor(SensorPort.S1); | |
light.setHigh(420); | |
light.setLow(270); | |
while (true) { | |
LCD.drawInt(light.readValue(), 4, 0, 0); | |
LCD.drawInt(light.readNormalizedValue(), 4, 0, 1); | |
LCD.drawInt(light.getLightValue(), 4, 0, 2); | |
// LCD.drawInt(SensorPort.S1.readValue(), 4, 0, 3); | |
Thread.sleep(2000); | |
} | |
} | |
} */ | |
import lejos.nxt.*; | |
import lejos.robotics.navigation.*; | |
public class LineClockwise { | |
public static void main(String[] args) throws Exception { | |
LightSensor light = new LightSensor(SensorPort.S1); | |
DifferentialPilot pilot = new DifferentialPilot(2.1f, 4.4f, Motor.A, Motor.B); | |
pilot.setTravelSpeed(5); | |
light.setHigh(420); | |
light.setLow(290); | |
//WhiteSpace | |
// LCD.drawInt(light.readNormalizedValue()); | |
// light.setHigh(); | |
// Thread.sleep(10000); | |
//BlackSpace | |
// LCD.drawInt(light.calibrateLow()); | |
// light.setLow(); | |
while(!Button.ESCAPE.isPressed()) { | |
LCD.drawInt(light.readValue(), 4, 0, 0); | |
if(light.readValue() <= 18 ) { | |
pilot.backward(); | |
} | |
// else if(light.readValue() >= 100) { | |
// | |
// pilot.rotate(50); | |
// } | |
else{ | |
// pilot.steer(-50,47); | |
pilot.rotate(-29); | |
pilot.travel(-.5); | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment