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); } }
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); }
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); } }
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++; } }
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 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(); }
public void Setup() { _mockParent = new Mock <IDigitalInputDevice>(MockBehavior.Strict); _pin = new DigitalInputPin(3, _mockParent.Object); }
/// <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) { }
/// <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)) { }