public void Run ()
        {
            // Create the blocks
            var button = new DigitalInputPin (buttonHardware);
            var led = new DigitalOutputPin (ledHardware);

            // Connect them
            button.Output.ConnectTo (led.Input);

            // Do nothing
            for (; ; ) {
                System.Threading.Thread.Sleep (1000);
            }
        }
Exemple #2
0
		public static void Main()
		{
			// Create the blocks
			var button = new DigitalInputPin(buttonHardware);
			var led = new DigitalOutputPin(ledHardware);

			// Connect them together. with the block/scope architecture, you can think
			// of everything as being connectable - output from one thing can be piped
			// into another. in this case, we're setting the button output to the LED
			// input. so when the user presses on the button, the signal goes straight
			// to the LED.
			button.Output.ConnectTo(led.Input);

			// keep the main loop alive so the program doesn't exit.
			while (true)
			{
				Thread.Sleep(1000);
			}
		}
        public void Run ()
        {
            // Create the blocks
            var button = new DigitalInputPin (buttonHardware);
            var pushButton = new PushButton ();
            var led = new DigitalOutputPin (ledHardware);

            // Connect them
            button.Output.ConnectTo (pushButton.DigitalInput);

            var ledState = 0;
            led.Input.Value = ledState;

            pushButton.Clicked += (s, e) => {
                ledState = 1 - ledState;
                led.Input.Value = ledState;
            };

            // Do nothing
            for (; ; ) {
                System.Threading.Thread.Sleep (1000);
            }
        }