/// <summary> /// This is where all sensors and motors are stopped /// </summary> public void DisconnectAll() { // Stop sensing if (LightIntensitySensor.IsSensing()) { LightIntensitySensor.StopSensing(); } if (SoundLevelSensor.IsSensing()) { SoundLevelSensor.StopSensing(); } if (SoundRatioSensor.IsSensing()) { SoundRatioSensor.StopSensing(); } if (UltrasonicSensor.IsSensing()) { UltrasonicSensor.StopSensing(); } if (TouchSensor.IsSensing()) { TouchSensor.StopSensing(); } //TODO clear sensors? // Stop behaviors if (WalkBehavior.IsWalking) { WalkBehavior.Stop(); } // Stop motors if (MotorTail.IsRunning) { MotorTail.Stop(); } if (MotorRight.IsRunning) { MotorRight.Stop(); } if (MotorLeft.IsRunning) { MotorLeft.Stop(); } System.Threading.Thread.Sleep(1000); Brick.Disconnect(); IsConnectionStarted = false; }
public void Forward(float leftSpeed, float rightSpeed) { if (leftSpeed >= 0) { MotorLeft.Forward(leftSpeed); } else { MotorLeft.Reverse(Math.Abs(leftSpeed)); } if (rightSpeed >= 0) { MotorRight.Forward(rightSpeed); } else { MotorRight.Reverse(Math.Abs(rightSpeed)); } }
public void Forward(float speed) { MotorLeft.Forward(speed); MotorRight.Forward(speed); }
public void Stop() { MotorLeft.Stop(); MotorRight.Stop(); }
public void SpinRight(float speed) { MotorLeft.Forward(speed); MotorRight.Reverse(speed); }
public void Reverse(float speed) { MotorLeft.Reverse(speed); MotorRight.Reverse(speed); }