/// <summary>
        /// Finch will try to get out of a room
        /// </summary>
        static void Maze()
        {
            DisplayHeader("Running");
            myFinch.wait(1000);
            Console.WriteLine("Trying to get out of the room...");

            int  speed    = 100;
            int  waitTime = 1000;
            bool running  = true;

            while (running)
            {
                myFinch.setLED(255, 255, 255);
                myFinch.setMotors(speed, speed);

                if (myFinch.isObstacleLeftSide())
                {
                    myFinch.setLED(0, 0, 255);
                    myFinch.setMotors(-speed, -speed);
                    myFinch.wait(waitTime);
                    myFinch.setMotors(speed, 0);
                    myFinch.wait(waitTime);
                    myFinch.setLED(255, 255, 255);
                }
                if (myFinch.isObstacleRightSide())
                {
                    myFinch.setLED(255, 0, 0);
                    myFinch.setMotors(-speed, -speed);
                    myFinch.wait(waitTime);
                    myFinch.setMotors(0, speed);
                    myFinch.wait(waitTime);
                    myFinch.setLED(255, 255, 255);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Talent Show
        /// </summary>
        /// <param name="finchRobot"></param>
        static void DisplayTalentShow(Finch finchRobot)
        {
            DisplayScreenHeader("Talent Show");

            Console.WriteLine("The Finch robot is ready to show you its talent.");
            DisplayContinuePrompt();


            //ENTER MY CODE HERE TO MOVE IT AND STUFF
            finchRobot.setMotors(75, 75);


            finchRobot.isObstacleLeftSide();
            finchRobot.isObstacleRightSide();

            Console.ReadKey(); finchRobot.setMotors(75, 75);


            finchRobot.isObstacleLeftSide();
            finchRobot.isObstacleRightSide();

            Console.ReadKey();

            finchRobot.setMotors(100, 75);


            finchRobot.isObstacleLeftSide();
            finchRobot.isObstacleRightSide();

            Console.ReadKey(); finchRobot.setMotors(100, 75);

            finchRobot.setLED(255, 0, 0);
            finchRobot.wait(9000);
            finchRobot.noteOn(10000);
            finchRobot.wait(1000);
            finchRobot.noteOff();

            finchRobot.setLED(0, 255, 0);
            finchRobot.wait(11000);
            finchRobot.noteOn(7000);
            finchRobot.wait(1500);

            finchRobot.setLED(0, 0, 255);
            finchRobot.wait(12000);
            finchRobot.noteOn(6500);
            finchRobot.wait(500);

            //for (int lightLevel = 0; lightLevel < 255; lightLevel++)
            //{
            //    finchRobot.setLED(234, 132, 0);
            //}

            DisplayContinuePrompt();
        }
Ejemplo n.º 3
0
        private static void AdvoidLightAndObsticales(Finch alma)
        {
            alma.connect();
            int light;
            int lightThreshold = 8;



            DisplayHeader("Finch flees before the spotlight");
            Console.WriteLine("Finch will Avoid the spotlight (flashlight) for 10 seconds. The Finch will also Avoid  Obsitacls");

            light = alma.getRightLightSensor();

            for (int i = 0; i < 17; i++)
            {
                alma.setMotors(100, 100);
                alma.setLED(0, 255, 0);
                alma.wait(500);

                //
                //avoid light
                //
                if ((lightThreshold + light) < alma.getRightLightSensor())
                {
                    alma.setMotors(255, 0);
                    alma.setLED(255, 0, 0);
                    alma.wait(500);
                    alma.setMotors(255, 255);
                    alma.setLED(255, 0, 0);
                    alma.wait(1500);
                    alma.setMotors(0, 255);
                    alma.setLED(255, 0, 0);
                    alma.wait(500);
                }
                if (alma.isObstacleLeftSide())
                {
                    alma.setMotors(0, 255);
                    alma.setLED(255, 0, 0);
                    alma.wait(500);
                }

                else if (alma.isObstacleRightSide())
                {
                    alma.setMotors(255, 0);
                    alma.setLED(255, 0, 0);
                }
            }
            alma.disConnect();
            DisplayContinuePrompt();
        }
Ejemplo n.º 4
0
        static void DisplayTimObstacle(string timSide, Finch tim)
        {
            DisplayHeader("Tim Obstacle Detection");

            if (timSide == "left")
            {
                Console.WriteLine($"Obstacle detected in Tims left eye: {tim.isObstacleLeftSide()}");
            }
            else if (timSide == "right")
            {
                Console.WriteLine($"Obstacle detected in Tims right eye: {tim.isObstacleRightSide()}");
            }

            DisplayKeyToContinue();
        }
Ejemplo n.º 5
0
        private static void advoidobstacles(Finch alma)
        {
            alma.connect();



            DisplayHeader("Finch Avoids Obstacles.");
            Console.WriteLine("Finch will Avoid  objects for 10 seconds. While moving in a straight line");
            for (int i = 0; i < 17; i++)
            {
                //
                //avoid obstiacles
                //
                if (alma.isObstacleLeftSide())
                {
                    alma.setMotors(0, 255);
                    alma.setLED(255, 0, 0);
                    alma.wait(500);
                }

                else if (alma.isObstacleRightSide())
                {
                    alma.setMotors(255, 0);
                    alma.setLED(255, 0, 0);
                    alma.wait(500);
                }
                else
                {
                    alma.setMotors(100, 100);
                    alma.setLED(0, 255, 0);
                    alma.wait(500);

                    DisplayHeader("Finch Avoids Obstacles.");
                    Console.WriteLine("Finch will Avoid  objects for 10 seconds. While moving in a straight line");
                    Console.WriteLine("No Obstacle Found");
                }
            }
            alma.disConnect();
            DisplayContinuePrompt();
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            // create Finch
            Finch bot = new Finch();

            bot.connect();

            Console.WriteLine("Start XGamepadApp");
            // Initialize XInput
            var controllers = new[] { new Controller(UserIndex.One), new Controller(UserIndex.Two), new Controller(UserIndex.Three), new Controller(UserIndex.Four) };

            // Get 1st controller available
            Controller controller = null;

            foreach (var selectControler in controllers)
            {
                if (selectControler.IsConnected)
                {
                    controller = selectControler;
                    break;
                }
            }

            if (controller == null)
            {
                Console.WriteLine("No XInput controller installed");
            }
            else
            {
                Console.WriteLine("Found a XInput controller available");

                while (controller.IsConnected)
                {
                    if (IsKeyPressed(ConsoleKey.Escape))
                    {
                        break;
                    }
                    var state    = controller.GetState();
                    var LeftJoyX = state.Gamepad.LeftThumbX;
                    var LeftJoyY = state.Gamepad.LeftThumbY;
                    //Console.WriteLine($"X: {LeftJoyX} Y: {LeftJoyY}");
                    int lmotor = (LeftJoyY / 128) + (LeftJoyX / 128);
                    int rmotor = (LeftJoyY / 128) - (LeftJoyX / 128);
                    bot.setMotors(lmotor, rmotor);
                    if (state.Gamepad.RightThumbY > 0)
                    {
                        bot.noteOn(state.Gamepad.RightThumbY / 20);
                    }
                    if (state.Gamepad.RightThumbY < 0)
                    {
                        bot.noteOn((-(state.Gamepad.RightThumbY)) / 20);
                    }
                    int Red   = 0;
                    int Green = 0;
                    int Blue  = 0;
                    if (state.Gamepad.Buttons == GamepadButtonFlags.B)
                    {
                        Red = Red + 255;
                        Console.WriteLine($"Temperature: {bot.getTemperature()}");
                    }
                    if (state.Gamepad.Buttons == GamepadButtonFlags.A)
                    {
                        Green = Green + 255;
                    }
                    if (state.Gamepad.Buttons == GamepadButtonFlags.X)
                    {
                        Blue = Blue + 255;
                    }
                    if (state.Gamepad.Buttons == GamepadButtonFlags.Y)
                    {
                        Red   = Red + 255;
                        Green = Green + 255;
                        Console.WriteLine($"Light Level: {bot.getLeftLightSensor()}");
                    }
                    bot.setLED(Red, Green, Blue);
                    while (bot.isObstacleLeftSide() || bot.isObstacleRightSide())
                    {
                        bot.setMotors(-255, -255);
                    }
                }
            }
            Console.WriteLine("End XGamepadApp");
            bot.disConnect();
        }