static void Reverse() { motorPair.Brake(); // set to reverse brick.MotorA = new NxtMotor(true); brick.MotorC = new NxtMotor(true); motorPair = new NxtMotorSync(brick.MotorA, brick.MotorC); motorPair.Run(75, 0, 0); Thread.Sleep(1000); motorPair.Brake(); }
private void Backward() { textBox1.Text += "Backward" + Environment.NewLine; if (motorPair != null) { motorPair.Brake(); } nxt.MotorB = new NxtMotor(true); nxt.MotorC = new NxtMotor(true); nxt.MotorB.ResetMotorPosition(true); nxt.MotorC.ResetMotorPosition(true); motorPair = new NxtMotorSync(nxt.MotorB, nxt.MotorC); motorPair.Run(100, 0, 0); nxtStatus[Motion.Forward] = false; nxtStatus[Motion.Back] = true; nxtStatus[Motion.TurnLeft] = false; nxtStatus[Motion.TurnRight] = false; nxtStatus[Motion.Brake] = false; }
static void Main() { Init(); brick = new NxtBrick(NxtCommLinkType.USB, 0); //brick = new NxtBrick(NxtCommLinkType.Bluetooth, 40); var sound = new NxtSoundSensor(); var touch = new NxtTouchSensor(); var sonar = new NxtUltrasonicSensor(); brick.MotorA = new NxtMotor(); brick.MotorC = new NxtMotor(); motorPair = new NxtMotorSync(brick.MotorA, brick.MotorC); brick.Sensor1 = sonar; brick.Sensor3 = touch; brick.Sensor4 = sound; sound.PollInterval = 50; sound.OnPolled += sound_OnPolled; sonar.PollInterval = 50; sonar.ThresholdDistanceCm = 25; sonar.OnPolled += sonar_OnPolled; sonar.OnWithinThresholdDistanceCm += OnWithinThreshold; sonar.ContinuousMeasurementCommand(); touch.PollInterval = 50; touch.OnPressed += OnCollision; brick.Connect(); motorPair.Run(75, 0, 0); Console.WriteLine("Press any key to stop."); Console.ReadKey(); brick.Disconnect(); }
public void ArcadeDrive(sbyte move, sbyte turn) { m_motors.Run(move, 0, turn); }
public void Turn(int direction) { _motorSync.Run(Config.TurnPower, 0, (sbyte)(Math.Sign(direction) * 100)); }