Ejemplo n.º 1
0
        void InputThread()
        {
            GT.Socket socket = GT.Socket.GetSocket(5, true, null, null);
            //Mainboard.TurnOnLed(6);

            DigitalInput p7 = DigitalInputFactory.Create(socket, GT.Socket.Pin.Three, GlitchFilterMode.Off, ResistorMode.PullDown, breakout);
            //Mainboard.TurnOnLed(7);

            DigitalInput p8 = DigitalInputFactory.Create(socket, GT.Socket.Pin.Four, GlitchFilterMode.Off, ResistorMode.PullDown, breakout);
            //Mainboard.TurnOnLed(8);

            DigitalInput p9 = DigitalInputFactory.Create(socket, GT.Socket.Pin.Five, GlitchFilterMode.Off, ResistorMode.PullDown, breakout);

            //Mainboard.TurnOnLed(9);

            while (true)
            {
                int    spd = 50;
                string cmd = GetCommand(p7, p8, p9);

                //Debug.Print("CMD " + cmd);
                switch (cmd)
                {
                case "STOP":
                    Mainboard.SetMotorSpeed(0, 0);
                    break;

                case "GO":
                    Mainboard.SetMotorSpeed(spd, spd);
                    break;

                case "LEFT":
                    Mainboard.SetMotorSpeed(spd, -spd);
                    break;

                case "RIGHT":
                    Mainboard.SetMotorSpeed(-spd, spd);
                    break;

                case "BACK":
                    Mainboard.SetMotorSpeed(-spd, -spd);
                    break;

                default:
                    Mainboard.SetMotorSpeed(0, 0);
                    break;
                }
            }
        }