BoeBot.java 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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(100);
  12. motor.setRichting(true);
  13. motor.start();
  14. while(true){
  15. if(botsingdetectie.detectEdge()){
  16. CPU.writePin(CPU.pin1,true);
  17. motor.noodStop();
  18. motor.setRichting(false);
  19. motor.start();
  20. CPU.delay(2000);
  21. motor.noodStop();
  22. motor.turn(180);
  23. motor.setRichting(true);
  24. motor.start();
  25. }else if(botsingdetectie.detectObject() == 1){
  26. motor.noodStop();
  27. motor.setRichting(false);
  28. motor.start();
  29. CPU.delay(2000);
  30. motor.noodStop();
  31. motor.turn(90);
  32. motor.setRichting(true);
  33. motor.start();
  34. }else if(botsingdetectie.detectObject() == 2){
  35. motor.noodStop();
  36. motor.setRichting(false);
  37. motor.start();
  38. CPU.delay(2000);
  39. motor.noodStop();
  40. motor.turn(270);
  41. motor.setRichting(true);
  42. motor.start();
  43. }else if(botsingdetectie.detectObject() == 3){
  44. motor.noodStop();
  45. motor.setRichting(false);
  46. motor.start();
  47. CPU.delay(2000);
  48. motor.noodStop();
  49. motor.turn(180);
  50. motor.setRichting(true);
  51. motor.start();
  52. }
  53. int getal = afir.detect(4);
  54. if(getal == 21)
  55. {
  56. afir.setStatus(!afir.getStatus());
  57. }
  58. if(afir.getStatus())
  59. {
  60. if(getal != -1){
  61. afir.verwerkSignaal(getal);
  62. }
  63. else
  64. {
  65. //some other code
  66. }
  67. }
  68. }
  69. }