Esempio n. 1
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);
            }
        }
Esempio n. 2
0
            public AwesomeBlock(Cpu.Pin buttonPin, Cpu.Pin ledPin, IDCMotor leftMotor, IDCMotor rightMotor)
            {
                var button = new DigitalInputPin(buttonPin);
                var led    = new DigitalOutputPin(ledPin);



                button.Output.ConnectTo(led.Input);
                button.Output.ConnectTo(rightMotor.SpeedInput);
                button.Output.ConnectTo(leftMotor.SpeedInput);
            }
Esempio n. 3
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);
            }
        }
Esempio n. 4
0
        public static void Main2()
        {
            //Create our "Blocks"
            var led    = new DigitalOutputPin(Pins.ONBOARD_LED);
            var button = new DigitalInputPin(Pins.ONBOARD_BTN);

            button.Output.ConnectTo(led.Input);

            int i = 0;

            while (true)
            {
                Thread.Sleep(1000); // sleep for 1000ms

                Debug.Print("Looping" + i);
                i++;
            }
        }
Esempio n. 5
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);
            }
        }
Esempio n. 6
0
        public static void Main6()
        {
            //Create our "Blocks"
            var button = new DigitalInputPin(Pins.ONBOARD_BTN);
            var led    = new DigitalOutputPin(Pins.ONBOARD_LED);


            var leftMotor = HBridgeMotor.CreateForNetduino(PWMChannels.PWM_PIN_D3, Pins.GPIO_PIN_D1, Pins.GPIO_PIN_D2);

            leftMotor.CalibrationInput.Value = 1;

            var rightMotor = HBridgeMotor.CreateForNetduino(PWMChannels.PWM_PIN_D6, Pins.GPIO_PIN_D4, Pins.GPIO_PIN_D5);

            rightMotor.CalibrationInput.Value = 1;



            button.Output.ConnectTo(led.Input);
            button.Output.ConnectTo(rightMotor.SpeedInput);
            button.Output.ConnectTo(leftMotor.SpeedInput);

            Thread.Sleep(Timeout.Infinite);
        }
 /// <summary>
 /// Creates an instance using the default GpioController and <see cref="GpioPinDriveMode.InputPullDown"/>.
 /// </summary>
 /// <param name="pin">The pin to use.</param>
 public ObservableDigitalInput(DigitalInputPin pin) :
     base((int)pin, GpioPinDriveMode.InputPullDown)
 {
     Init();
 }
 /// <summary>
 /// Creates an instance using the default GpioController and a specific pin drive mode.
 /// </summary>
 /// <param name="pin">The pin to use.</param>
 /// <param name="driveMode">The mode of the pin. This must be valid for input.</param>
 public ObservableDigitalInput(DigitalInputPin pin, GpioPinDriveMode mode) :
     base((int)pin, DigitalInputOutputBase.CheckInputMode(mode))
 {
     Init();
 }
Esempio n. 9
0
 public void Setup()
 {
     _mockParent = new Mock <IDigitalInputDevice>(MockBehavior.Strict);
     _pin        = new DigitalInputPin(3, _mockParent.Object);
 }
Esempio n. 10
0
 /// <summary>
 /// Creates an instance using the default GpioController and <see cref="GpioPinDriveMode.InputPullDown"/>.
 /// </summary>
 /// <param name="pin">The pin to use.</param>
 public DigitalInput(DigitalInputPin pin) :
     base((int)pin, GpioPinDriveMode.InputPullDown)
 {
 }
Esempio n. 11
0
 /// <summary>
 /// Creates an instance using the default GpioController and a specific pin drive mode.
 /// </summary>
 /// <param name="pin">The pin to use.</param>
 /// <param name="driveMode">The mode of the pin. This must be valid for input.</param>
 public DigitalInput(DigitalInputPin pin, GpioPinDriveMode mode) :
     base((int)pin, DigitalInputOutputBase.CheckInputMode(mode))
 {
 }