| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- package boebot;
- import stamp.core.*;
- public class BoeBot{
- MotorAansturing motor;
- Botsingdetectie botsingdetectie;
- FysiekeIndicator fysiekeindicator;
- public BoeBot(){
- motor = new MotorAansturing();
- botsingdetectie = new Botsingdetectie();
- fysiekeindicator = new FysiekeIndicator();
- motor.setSnelheid(100);
- motor.setRichting(true);
- motor.start();
- while(true){
- if(botsingdetectie.detectEdge()){
- CPU.writePin(CPU.pin1,true);
- motor.noodStop();
- motor.setRichting(false);
- motor.start();
- CPU.delay(2000);
- motor.noodStop();
- motor.turn(180);
- motor.setRichting(true);
- motor.start();
- }else if(botsingdetectie.detectObject() == 1){
- motor.noodStop();
- motor.setRichting(false);
- motor.start();
- CPU.delay(2000);
- motor.noodStop();
- motor.turn(90);
- motor.setRichting(true);
- motor.start();
- }else if(botsingdetectie.detectObject() == 2){
- motor.noodStop();
- motor.setRichting(false);
- motor.start();
- CPU.delay(2000);
- motor.noodStop();
- motor.turn(270);
- motor.setRichting(true);
- motor.start();
- }else if(botsingdetectie.detectObject() == 3){
- motor.noodStop();
- motor.setRichting(false);
- motor.start();
- CPU.delay(2000);
- motor.noodStop();
- motor.turn(180);
- motor.setRichting(true);
- motor.start();
- }
- CPU.delay(1000);
- }
- }
- }
|