예제 #1
0
        /// <summary>
        /// module: Alarm System
        /// </summary>
        static void AlarmSystem(Finch finchRobot)
        {
            string alarmType;
            int maxSeconds;
            double upperThreshold;
            double lowerThreshold;
            bool thresholdExceeded;

            DisplayScreenHeader("Alarm System");

            alarmType = DisplayGetAlarmType();
            maxSeconds = DisplayGetMaxSeconds();
            DisplayGetThreshhold(finchRobot, alarmType, out lowerThreshold, out upperThreshold);
            Console.WriteLine();
            Console.WriteLine("Once you continue the alarm will be set");
            DisplayContinuePrompt();
            finchRobot.setLED(0, 255, 0);
            thresholdExceeded = MonitorLevels(finchRobot, lowerThreshold, upperThreshold, maxSeconds, alarmType);

            if (thresholdExceeded)
            {
                if (alarmType == "light")
                {
                    Console.WriteLine("Maximum or minimum light level exceeded");

                }
                else
                {
                    Console.WriteLine("Maximum or minimum temperature level exceeded");
                }

                finchRobot.setLED(255, 0, 0);
                for (int i = 0; i < 5; i++)
                {
                    finchRobot.noteOn(5000);
                    finchRobot.wait(500);
                    finchRobot.noteOff();
                    finchRobot.wait(500);
                }

            }
            else
            {
                Console.WriteLine();
                Console.WriteLine("Maximum time exceeded");
            }


            DisplayContinuePrompt();
            finchRobot.noteOff();
            finchRobot.setLED(0, 0, 0);
        }
예제 #2
0
        /// <summary>
        /// connect the Finch robot to the application
        /// </summary>
        static bool DisplayConnectFinchRobot(Finch finchRobot)
        {
            const int MAX_ATTEMPTS = 3;
            int attempts = 0;
            bool finchRobotConnected;

            DisplayScreenHeader("Connect Finch Robot");

            Console.WriteLine("\tConnecting to the Finch robot. Be sure the USB cord is plugged into both the robot and the computer.");
            Console.WriteLine();
            DisplayContinuePrompt();

            //
            // loop until the Finch robot is connected or the maximum number of attempts is exceeded
            //
            do
            {
                //
                // increment attempt counter
                //
                attempts++;

                finchRobotConnected = finchRobot.connect();

                if (!finchRobotConnected)
                {
                    Console.WriteLine();
                    Console.WriteLine("\tUnable to connect to the Finch robot. Please confirm all USB cords are plugged in.");
                    Console.WriteLine();
                    DisplayContinuePrompt();
                }
            } while (!finchRobot.connect() && attempts < MAX_ATTEMPTS);

            //
            // notify the user if the maximum attempts is exceeded
            //
            if (finchRobotConnected)
            {
                Console.WriteLine();
                Console.WriteLine("\tFinch robot is now connected.");
                Console.WriteLine();
                finchRobot.setLED(0, 255, 0); // set nose to green
                finchRobot.wait(3000);
                finchRobot.setLED(0, 0, 0);
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine("\tUnable to connect to the Finch robot. Please check connection and try again.");
                Console.WriteLine();
            }

            DisplayContinuePrompt();

            return finchRobotConnected;
        }
예제 #3
0
        /// <summary>
        /// module: Talent Show
        /// </summary>
        static void TalentShow(Finch finchRobot)
        {
            string userResponse;
            DisplayScreenHeader("Talent Show");

            Console.WriteLine("The Finch robot will now show its talent.");
            DisplayContinuePrompt();

            for (int i = 0; i < 255; i++)
            {
                finchRobot.setLED(0, i, 0);
                finchRobot.noteOn(i * 100);
                finchRobot.setMotors(i, i);
            }

            finchRobot.setLED(0, 255, 0);
            finchRobot.setMotors(-100, -100);
            finchRobot.wait(1000);
            RobotStopAll(finchRobot);
            finchRobot.wait(1000);

            finchRobot.setLED(0, 0, 255);
            finchRobot.setMotors(100, 100);
            finchRobot.wait(1000);
            RobotStopAll(finchRobot);
            finchRobot.wait(1000);

            finchRobot.setLED(255, 50, 255);
            finchRobot.setMotors(-255, -255);
            finchRobot.wait(1000);
            RobotStopAll(finchRobot);
            finchRobot.wait(1000);



            RobotStopAll(finchRobot);
            finchRobot.wait(1000);

            finchRobot.setMotors(50, 255);
            finchRobot.wait(500);
            finchRobot.setMotors(-50, -255);
            finchRobot.wait(500);

            finchRobot.setMotors(255, 50);
            finchRobot.wait(500);
            finchRobot.setMotors(-255, -50);
            finchRobot.wait(500);
            RobotStopAll(finchRobot);

            Console.WriteLine();
            do
            {
                Console.WriteLine("Would you like to hear a song?");
                userResponse = Console.ReadLine().ToLower();
                if (userResponse == "yes")
                {
                    Console.WriteLine();
                    Console.WriteLine("That is too bad because I can't find anything on the internet that breaks songs down to simple frequencies");
                    Console.WriteLine("Also, I have no talent so I can't make a song, here is a bunch of beeps though.");
                    PlaySong(finchRobot);
                }

                else if (userResponse == "no")
                {
                    Console.WriteLine("Wow, you upset the Finch.");
                }

                else
                {
                    Console.WriteLine($"I don't understand what {userResponse} means, please answer yes or no");
                    userResponse = "retry";
                }
            } while (userResponse == "retry");

            Console.WriteLine();
            Console.WriteLine("That's all folks.");
            DisplayContinuePrompt();
        }