Beispiel #1
0
        public static void Main()
        {
            // Setup GoBus ports
            led1 = new NetduinoGo.RgbLed(GoSockets.Socket8);
            led2 = new NetduinoGo.RgbLed(GoSockets.Socket7);
            led3 = new NetduinoGo.RgbLed(GoSockets.Socket6);
            button1 = new NetduinoGo.Button(GoSockets.Socket1);
            button2 = new NetduinoGo.Button(GoSockets.Socket3);
            InterruptPort settingButton = new InterruptPort(Pins.Button, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);
            settingButton.OnInterrupt += new NativeEventHandler(settingButton_OnInterrupt);
            OutputPort powerlight = new OutputPort(Pins.PowerLed, false);

            #if !mute
            buzzer = new NetduinoGo.PiezoBuzzer();
            #endif

            // Set Scale
            SetScale();

            // Register Buttons
            button1.ButtonPressed += new NetduinoGo.Button.ButtonEventHandler(button1_ButtonPressed);
            button2.ButtonPressed += new NetduinoGo.Button.ButtonEventHandler(button2_ButtonPressed);
            led2.SetColor(0, 0, 255);
            // Main thread sleep time
            Thread.Sleep(Timeout.Infinite);
        }
Beispiel #2
0
        public static void Main()
        {
            var blueButton = new NetduinoGo.Button(GoSockets.Socket1);
            var redButton = new NetduinoGo.Button(GoSockets.Socket4);
            var led = new NetduinoGo.RgbLed();
            var potentimoter = new NetduinoGo.Potentiometer();
            var blue = new Rgb(255, 0, 0);
            var red = new Rgb(0, 0, 255);
            var selectedColour = blue;

            blueButton.ButtonReleased += (sender, state) =>
                                             {
                                                 selectedColour = blue;
                                             };
            redButton.ButtonReleased += (sender, state) =>
                                            {
                                                selectedColour = red;
                                            };
            led.SetColor(selectedColour.Red, selectedColour.Green, selectedColour.Blue);

            while (true)
            {
                var intensity = potentimoter.GetValue();
                led.SetColor((byte)(selectedColour.Red * intensity), (byte)(selectedColour.Green * intensity), (byte)(selectedColour.Blue * intensity));
            }
        }