larseh created page: Lesson10Week14 authored by Lars Eriksen Høeg's avatar Lars Eriksen Høeg
...@@ -126,15 +126,16 @@ The legocar has same physical design as in the experiments described above. ...@@ -126,15 +126,16 @@ The legocar has same physical design as in the experiments described above.
A simple solution would be to use a sequantial loop if we know the position of the obstacle. Such a solution could be like this where we use a predetermined route[PilotAvoid]: A simple solution would be to use a sequantial loop if we know the position of the obstacle. Such a solution could be like this where we use a predetermined route[PilotAvoid]:
public void go()
public void go()
{ {
LCD.clear(); LCD.clear();
Sound.beep(); Sound.beep();
while ( ! Button.ENTER.isDown()) Thread.yield(); while ( ! Button.ENTER.isDown()) Thread.yield();
Sound.twoBeeps(); Sound.twoBeeps();
LCD.drawInt(sonar.getDistance(), 2, 2); LCD.drawInt(sonar.getDistance(), 2, 2);
pilot.travel(50, true); pilot.travel(50, true);
while(pilot.isMoving()){ while(pilot.isMoving()){
if(sonar.getDistance() < 10){ if(sonar.getDistance() < 10){
... ...
......