コード例 #1
0
        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);
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Roddoric/Monkey.Robotics
		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);
			}
		}
コード例 #3
0
        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);
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: Roddoric/Monkey.Robotics
		public static void Main ()
		{
			// Create the blocks
			var leftLight = new DigitalOutputPin (Pins.GPIO_PIN_D10) { Name = "LeftLight" };
			var rightLight = new DigitalOutputPin (Pins.GPIO_PIN_D11) { Name = "RightLight" };

			// Init
			leftLight.Input.Value = 0;
			rightLight.Input.Value = 0;

			// Create the control server
			var serialPort = new SerialPort (SerialPorts.COM3, 57600, Parity.None, 8, StopBits.One);
			serialPort.Open ();
			var server = new ControlServer (serialPort);

			// Expose the left and right lights to the control server
			leftLight.Input.ConnectTo (server, writeable: true);
			rightLight.Input.ConnectTo (server, writeable: true);

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