コード例 #1
0
        public override void TeleopPeriodic()
        {
            if (joystick.GetRawButton(1))
            {
                servo.Set(0.0);
            }
            else if (joystick.GetRawButton(2))
            {
                servo.Set(1.0);
            }

            else
            {
                servo.Set(0.5);
            }
        }
コード例 #2
0
 public void TestServoSet()
 {
     using (Servo s = NewServo())
     {
         s.Set(1.0);
         Assert.AreEqual(s.Get(), 1.0);
     }
 }
コード例 #3
0
        static void Main()
        {
            // Servos have 3 pins The middle one is always power. Then black or brown side is ground.
            // The remaining pin is the signal that needs PWM.

            var controller = PwmController.FromName(FEZ.PwmChannel.Controller1.Id);
            var channel    = controller.OpenChannel(FEZ.PwmChannel.Controller1.D3);
            var servo      = new Servo(controller, channel);

            // This is for continous servos
            // Speed is anywhere -100 to 100
            servo.ConfigureAsContinuous(false);
            var speed = 1;

            while (true)
            {
                servo.Set(speed);
                if ((speed += 10) > 100)
                {
                    speed = -100;
                }
                Thread.Sleep(100);
            }

            /*
             * // This is for positional servos
             * // Pos is anywhere 0 to 180
             * servo.ConfigureAsPositional(false);
             * var pos = 1;
             * while (true) {
             *  servo.Set(pos);
             *  if ((pos += 10) > 180)
             *      pos = 1;
             *  Thread.Sleep(100);
             * }*/
        }