Ejemplo n.º 1
0
        //END RC constants
        public static void Main()
        {
            //RC stuff

                // Setup steering servo
                steering = new Servo(Pins.GPIO_PIN_D9);

                // Setup ESC
                xl5 = new SpeedController(Pins.GPIO_PIN_D10, new TRAXXAS_XL5());
                xl5.DriveMode = SpeedController.DriveModes.Forward;

            //End RC stuff

            Listener webServer = new Listener(RequestReceived);

            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
            while (true)
            {
                // Blink LED to show we're still responsive
                led.Write(!led.Read());
                Thread.Sleep(500);
            }
        }
Ejemplo n.º 2
0
        public static void Main()
        {
            // Setup steering servo
            steering = new Servo(Pins.GPIO_PIN_D9);

            // Setup ESC
            xl5 = new SpeedController(Pins.GPIO_PIN_D10, new TRAXXAS_XL5());
            xl5.DriveMode = SpeedController.DriveModes.Forward;

            // Setup PPM decoder channels
            //throttleChannel = new PPM_Channel(Pins.GPIO_PIN_D7);
            //steeringChannel = new PPM_Channel(Pins.GPIO_PIN_D6);

            // Set the servo channel to proper output scaling
            //steeringChannel.calibrateOutput(0, 180);

            // Sweep the wheels from left to right
            for (int i = 0; i <= 30; i++)
            {
                steering.Degree = i * 6;
                Thread.Sleep(30);
            }

            // Center steering
            steering.Degree = 90.5;

            // Switch to RC control mode
            while (true)
            {
                // Set the steering servo to the PPM wave
                //steering.Degree = steeringChannel.Read;

                steering.Degree = 0;

                // Get the throttle input
                //int throttleIn = throttleChannel.Read;
                int throttleIn = 50;

                // Figure out which direction we are going
                if (throttleIn >= 0)
                    xl5.DriveMode = SpeedController.DriveModes.Forward;
                else
                {
                    // Set ESC to reverse
                    //xl5.DriveMode = SpeedController.DriveModes.Reverse;

                    // Flip the negative to a positive
                    //throttleIn = throttleIn * -1;

                    // For now, let's just pull the throttle all the way out
                    xl5.Throttle = 0;
                }

                // Are we going too fast?
                if (throttleIn > speedLimit)
                    throttleIn = speedLimit;

                // Set the throttle
                xl5.Throttle = throttleIn;

            }
        }
Ejemplo n.º 3
0
        public static void Main()
        {
            // write your code here
            servo = new Servo(Pins.GPIO_PIN_D9);
            servo.Degree = servo_degree;

            greenled = new OutputPort(Pins.GPIO_PIN_D3, true);
            blueled = new OutputPort(Pins.GPIO_PIN_D4, true);
            redled = new OutputPort(Pins.GPIO_PIN_D5, true);

            whitebutton = new OutputPort(Pins.GPIO_PIN_D0, true);
            blackbutton = new OutputPort(Pins.GPIO_PIN_D1, true);
            redbutton = new OutputPort(Pins.GPIO_PIN_D2, true);
            bluebutton = new OutputPort(Pins.GPIO_PIN_D6, true);
            greenbutton = new OutputPort(Pins.GPIO_PIN_D7, true);
            yellowbutton = new OutputPort(Pins.GPIO_PIN_D8, true);

            bool whitestate = false;
            bool whitestate_prev = false;
            bool blackstate = false;
            bool blackstate_prev = false;
            bool redstate = false;
            bool redstate_prev = false;
            bool bluestate = false;
            bool bluestate_prev = false;
            bool greenstate = false;
            bool greenstate_prev = false;
            bool yellowstate = false;
            bool yellowstate_prev = false;

            while (true)
            {
                if (AcceptInput)
                {
                    whitestate = whitebutton.Read();
                    if ((whitestate_prev == true) && (whitestate == false))
                    {
                        WhitePressed();
                        RecordAndCheckUserStep(3);
                    }
                    whitestate_prev = whitestate;

                    blackstate = blackbutton.Read();
                    if ((blackstate_prev == true) && (blackstate == false))
                        BlackPressed();
                    blackstate_prev = blackstate;

                    yellowstate = yellowbutton.Read();
                    if ((yellowstate_prev == true) && (yellowstate == false))
                    {
                        YellowPressed();
                        RecordAndCheckUserStep(4);
                    }
                    yellowstate_prev = yellowstate;

                    redstate = redbutton.Read();
                    if ((redstate_prev == true) && (redstate == false))
                    {
                        TurnOffLED(COLORS.RED);
                        RecordAndCheckUserStep(0);
                    }
                    else if ((redstate_prev == false) && (redstate == true))
                        TurnOnLED(COLORS.RED);
                    redstate_prev = redstate;

                    bluestate = bluebutton.Read();
                    if ((bluestate_prev == true) && (bluestate == false))
                    {
                        TurnOffLED(COLORS.BLUE);
                        RecordAndCheckUserStep(2);
                    }
                    else if ((bluestate_prev == false) && (bluestate == true))
                        TurnOnLED(COLORS.BLUE);
                    bluestate_prev = bluestate;

                    greenstate = greenbutton.Read();
                    if ((greenstate_prev == true) && (greenstate == false))
                    {

                        TurnOffLED(COLORS.GREEN);
                        RecordAndCheckUserStep(1);
                    }
                    else if ((greenstate_prev == false) && (greenstate == true))
                        TurnOnLED(COLORS.GREEN);
                    greenstate_prev = greenstate;
                }
            }
        }