BoeBot.java 941 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package boebot;
  2. import stamp.core.*;
  3. public class BoeBot{
  4. MotorAansturing motor;
  5. Botsingdetectie botsingdetectie;
  6. FysiekeIndicator fysiekeindicator;
  7. public BoeBot(){
  8. motor = new MotorAansturing();
  9. botsingdetectie = new Botsingdetectie();
  10. fysiekeindicator = new FysiekeIndicator();
  11. motor.setSnelheid(50);
  12. motor.setRichting(true);
  13. motor.start();
  14. while(true){
  15. if(botsingdetectie.detectEdge()){
  16. fysiekeindicator.setLed1(false);
  17. fysiekeindicator.setLed2(false);
  18. } else{
  19. fysiekeindicator.setLed1(true);
  20. fysiekeindicator.setLed2(true);
  21. motor.noodStop();
  22. motor.setRichting(false);
  23. motor.start();
  24. CPU.delay(3000);
  25. motor.noodStop();
  26. motor.turn(180);
  27. motor.setRichting(true);
  28. motor.start();
  29. }
  30. CPU.delay(1000);
  31. }
  32. }
  33. }