Ejemplo n.º 1
0
        void MainLoop()
        {
            if (!nxt.IsMotorControlRunning())
            {
                nxt.StartMotorControl();
            }

            if (MoveState && !jump)
            {
                if (currentDir != USSDirection.Straight)
                {
                    USS_Direct(USSDirection.Straight);
                }
                motors.Run(100, Convert.ToByte(Convert.ToInt16(textBox2.Text)), 0);
                MA++;
                System.Threading.Thread.Sleep(1000);
                return;
            }

            USS_Direct(USSDirection.Right);
            if (MoveState)
            {
                motors.Run(100, Convert.ToByte(Convert.ToInt16(textBox5.Text)), Convert.ToSByte(Convert.ToInt16(textBox4.Text)));
                System.Threading.Thread.Sleep(1000);
                USS_Direct(USSDirection.Straight);
                jump = false;
                return;
            }
            else
            {
                USS_Direct(USSDirection.Left);
                if (MoveState)
                {
                    motors.Run(100, Convert.ToByte(Convert.ToInt16(textBox5.Text)), Convert.ToSByte(Convert.ToInt16(textBox3.Text)));
                    System.Threading.Thread.Sleep(1000);
                    USS_Direct(USSDirection.Straight);
                    jump = false;
                    return;
                }
                else
                {
                    jump = true;
                    for (uint i = MA; i > 0; i--)
                    {
                        motors.Run(-100, 229, 0);
                        System.Threading.Thread.Sleep(800);
                    }
                    return;
                }
            }
        }
Ejemplo n.º 2
0
 private void button_forward_Click(object sender, EventArgs e)
 {
     //Run both motors
     if (isConnectedToBrick)
     {
         if (RB_McRXE.Checked)
         {
             McMotorPair.Run(50, 180, 0);
         }
         else
         {
             motorB.Run(50, 180);
             motorC.Run(50, 100);
         }
     }
 }
 public void Run(double units)
 {
     _motorSync.Run(Config.RunPower, 0, 0);
 }