当前位置: 首页>>代码示例>>C#>>正文


C# GpioPin.Write方法代码示例

本文整理汇总了C#中Windows.Devices.Gpio.GpioPin.Write方法的典型用法代码示例。如果您正苦于以下问题:C# GpioPin.Write方法的具体用法?C# GpioPin.Write怎么用?C# GpioPin.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.Devices.Gpio.GpioPin的用法示例。


在下文中一共展示了GpioPin.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitAsync

        public async Task InitAsync()
        {
            if (!init)
            {
                var gpio = GpioController.GetDefault();

                if (gpio != null)
                {
                    gpioPinTrig = gpio.OpenPin(trigGpioPin);
                    gpioPinEcho = gpio.OpenPin(echoGpioPin);
                    gpioPinTrig.SetDriveMode(GpioPinDriveMode.Output);
                    gpioPinEcho.SetDriveMode(GpioPinDriveMode.Input);
                    gpioPinTrig.Write(GpioPinValue.Low);

                    //first time ensure the pin is low and wait two seconds
                    gpioPinTrig.Write(GpioPinValue.Low);
                    await Task.Delay(2000);
                    init = true;
                }
                else
                {
                    throw new InvalidOperationException("Gpio not present");
                }
            }
        }
开发者ID:jmservera,项目名称:Rover,代码行数:25,代码来源:UltrasonicDistanceSensor.cs

示例2: TLC5947ControllerBase

        //
        // Constructor
        //
        public TLC5947ControllerBase(uint latchPin, uint blackoutPin)
        {
            // Create the controller
            m_controller = new LedController(this, ControlerUpdateType.AllSlots);

            // Open the latch pin
            GpioController controller = GpioController.GetDefault();
            m_latchPin = controller.OpenPin((int)latchPin);
            m_latchPin.SetDriveMode(GpioPinDriveMode.Output);

            // Open the black out pin, set it high and low to reset the device.
            m_blackoutPin = controller.OpenPin((int)blackoutPin);
            m_blackoutPin.SetDriveMode(GpioPinDriveMode.Output);
            m_blackoutPin.Write(GpioPinValue.High);
            m_blackoutPin.Write(GpioPinValue.Low);

            // Create a async task to setup SPI
            new Task(async () =>
            {
                // Create the settings
                var settings = new SpiConnectionSettings(SPI_CHIP_SELECT_LINE);
                // Max SPI clock frequency, here it is 30MHz
                settings.ClockFrequency = 30000000;
                settings.Mode = SpiMode.Mode0;
                //  Find the selector string for the SPI bus controller
                string spiAqs = SpiDevice.GetDeviceSelector(SPI_CONTROLLER_NAME);
                // Find the SPI bus controller device with our selector string
                var devicesInfo = await DeviceInformation.FindAllAsync(spiAqs);
                // Create an SpiDevice with our bus controller and SPI settings
                m_spiDevice = await SpiDevice.FromIdAsync(devicesInfo[0].Id, settings);
            }).Start();
        }
开发者ID:QuinnDamerell,项目名称:WindowsIotLedDriver,代码行数:35,代码来源:TLC5947ControllerBase.cs

示例3: Configure

 public void Configure(GpioPin gpioPin)
 {
     _gpioPin = gpioPin;
     // init the pin
     _gpioPin.SetDriveMode(GpioPinDriveMode.Output);
     _gpioPin.Write(GpioPinValue.High);
     _gpioPin.Write(GpioPinValue.Low);
     _gpioPin.Write(GpioPinValue.High);
 }
开发者ID:codevelopnz,项目名称:SmartSolarDevice,代码行数:9,代码来源:GpioOutputConnection.cs

示例4: Zone

        public Zone(string id, GpioPin pin)
        {
            _id = id;
            _pin = pin;
            _pin.Write(GpioPinValue.Low);
            _pin.SetDriveMode(GpioPinDriveMode.Output);
            _pin.Write(GpioPinValue.High);            
            _state = OFF_STATE;

        }
开发者ID:micklab,项目名称:isavewater,代码行数:10,代码来源:zone.cs

示例5: Initialize

        public void Initialize()
        {
            var gpioController = GpioController.GetDefault();
            
            _mosiPin = gpioController.OpenPin(_mosi);
            _misoPin = gpioController.OpenPin(_miso);
            _clkPin = gpioController.OpenPin(_clk);
            _csPin = gpioController.OpenPin(_cs);

            _mosiPin.Write(GpioPinValue.Low);
            _mosiPin.Write(GpioPinValue.Low);
            _clkPin.Write(GpioPinValue.Low);
            _csPin.Write(GpioPinValue.High);
        }
开发者ID:ajbowen249,项目名称:RasPiLCDSandbox,代码行数:14,代码来源:OsoyooCustomSPI.cs

示例6: InitGPIO

        private void InitGPIO()
        {
            var gpio = GpioController.GetDefault();

            // error prompt
            if (gpio == null) {
                GpioStatus.Text = "There's no GPIO controller on this device";
                return -1;
            }

            buttonPin = gpio.OpenPin(BUTTON_PIN);
            ledPin = gpio.OpenPin(LED_PIN);

            // init LED to OFF by HIGH, cuz LED is wired in LOW config
            ledPin.Write(GpioPinValue.High);
            ledPin.SetDriveMode(GpioPinDriveMode.Output);

            // checking if input pull-up resistors are supported
            if (buttonPin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp)) {
                buttonPin.SetDriveMode(GpioPinDriveMode.InputPullUp);
            }
            else {
                buttonPin.SetDriveMode(GpioPinDriveMode.Input);
            }

            // setting debounce timeout
            buttonPin.DebounceTimeout = TimeSpan.FromMilliseconds(50);

            // register for ValueChanged event
            // so buttonPin_ValueChanged()
            // is called when button is pressed
            buttonPin.ValueChanged += buttonPin_ValueChanged;

            GpioStatus.Text = "GPIO pins initialized correctly";
        }
开发者ID:btlone,项目名称:Quiet-Maker,代码行数:35,代码来源:PushButton.cs

示例7: InitGPIO

        private void InitGPIO()
        {
            if (!ApiInformation.IsTypePresent(GpioPresentNS))
            {
                return;
            }

            var gpio = GpioController.GetDefault();
            if (gpio == null)
            {
                Debug.WriteLine("There is no GPIO controller on this device.");
                return;
            }

            var buttonPin = gpio.OpenPin(ButtonPin);
            ledPin = gpio.OpenPin(LedPin);

            // Initialize LED to the OFF state by first writing a HIGH value
            // We write HIGH because the LED is wired in a active LOW configuration
            ledPin.Write(GpioPinValue.High);
            ledPin.SetDriveMode(GpioPinDriveMode.Output);

            // Check if input pull-up resistors are supported
            if (buttonPin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp))
                buttonPin.SetDriveMode(GpioPinDriveMode.InputPullUp);
            else
                buttonPin.SetDriveMode(GpioPinDriveMode.Input);

            // Set a debounce timeout to filter out switch bounce noise from a button press
            buttonPin.DebounceTimeout = TimeSpan.FromMilliseconds(100);

            buttonPin.ValueChanged += ButtonPin_ValueChanged;
        }
开发者ID:DotNETForDevices,项目名称:IoTSamples,代码行数:33,代码来源:MainPage.xaml.cs

示例8: InitGPIO

        private void InitGPIO()
        {
            // get the GPIO controller
            var gpio = GpioController.GetDefault();

            // return an error if there is no gpio controller
            if (gpio == null)
            {
                led = null;
                GpioStatus.Text = "There is no GPIO controller.";
                return;
            }

            // set up the LED on the defined GPIO pin
            // and set it to High to turn off the LED
            led = gpio.OpenPin(ledPin);
            led.Write(GpioPinValue.High);
            led.SetDriveMode(GpioPinDriveMode.Output);

            // set up the PIR sensor's signal on the defined GPIO pin
            // and set it's initial value to Low
            pir = gpio.OpenPin(pirPin);
            pir.SetDriveMode(GpioPinDriveMode.Input);

            //ID is the Pin number
            sensor1.SensorId = pir.PinNumber.ToString();
            sensor1.SensorType = "PIR";
            sensors[node1.CurrentSensor] = sensor1;

            GpioStatus.Text = "GPIO pins initialized correctly.";
        }
开发者ID:CampusInnovators,项目名称:FakeData,代码行数:31,代码来源:MainPage.xaml.cs

示例9: InitGPIO

        private void InitGPIO()
        {
            _pin = GpioController.GetDefault().OpenPin(_pinNumber);

            _pin.Write(GpioPinValue.High);
            _pin.SetDriveMode(GpioPinDriveMode.Output);
        }
开发者ID:FaithZeroWigs,项目名称:VoiceRover,代码行数:7,代码来源:BlinkyDriver.cs

示例10: InitGPIO

        private void InitGPIO()
        {
            var gpio = GpioController.GetDefault();

            // Show an error if there is no GPIO controller
            if (gpio == null)
            {
                pin = null;
                Debug.WriteLine("There is no GPIO controller on this device.");
                return;
            }

            pin = gpio.OpenPin(LED_PIN);

            // Show an error if the pin wasn't initialized properly
            if (pin == null)
            {
                Debug.WriteLine("There is no GPIO controller on this device.");
                return;
            }

            pin.Write(GpioPinValue.High);
            pin.SetDriveMode(GpioPinDriveMode.Output);

            Debug.WriteLine("There is no GPIO controller on this device.");
        }
开发者ID:bospoort,项目名称:Win10UWPDemo,代码行数:26,代码来源:MainPage.xaml.cs

示例11: StartScenario

        void StartScenario()
        {
            // Initialize the GPIO objects.
            var gpio = GpioController.GetDefault();

            // Set up our GPIO pin for setting values.
            // If this next line crashes with a NullReferenceException,
            // then the problem is that there is no GPIO controller on the device.
            setPin = gpio.OpenPin(SET_PIN);

            // Establish initial value and configure pin for output.
            setPin.Write(currentValue);
            setPin.SetDriveMode(GpioPinDriveMode.Output);

            // Set up our GPIO pin for listening for value changes.
            listenPin = gpio.OpenPin(LISTEN_PIN);

            // Configure pin for input and add ValueChanged listener.
            listenPin.SetDriveMode(GpioPinDriveMode.Input);
            listenPin.ValueChanged += Pin_ValueChanged;

            // Start toggling the pin value every 500ms.
            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(500);
            timer.Tick += Timer_Tick;
            timer.Start();
        }
开发者ID:ChSchmidt81,项目名称:Windows-universal-samples,代码行数:27,代码来源:Scenario2_Listen.xaml.cs

示例12: OutputPin

 public OutputPin(int pinNumber, string name)
     : base(name, "output")
 {
     pin = gpio.OpenPin((int)pinNumber, GpioSharingMode.Exclusive);
     pin.SetDriveMode(GpioPinDriveMode.Output);
     pin.Write(GpioPinValue.Low);
 }
开发者ID:StephanieMak,项目名称:IoT-Maker-Den-Windows-for-IoT,代码行数:7,代码来源:OutputPin.cs

示例13: InitGPIO

        public bool InitGPIO()
        {
            //compiler directive to check whether it's running on the correct system.
            #if NETFX_CORE
            var gpio = GpioController.GetDefault();
            if (gpio == null)
            {
                pin = null;
                status = "There is no GPIO controller on this device";
                return false;
            }

            //If you have an LED on pin 2 - otherwise change the number
            pin = gpio.OpenPin(2);

            //make sure the pin has been initialised correctly
            if (pin == null)
            {
                status = "There was a problem initialising the GPIO Pin";
                return false;
            }

            pin.Write(GpioPinValue.High);
            pin.SetDriveMode(GpioPinDriveMode.Output);
            status = "GPIO pin is set correctly";
            return true;

            #else
            status = "NO GPIO Hardware";
            return true;
            #endif
        }
开发者ID:AerisHime,项目名称:Win10IoTUnity,代码行数:32,代码来源:Plugin.cs

示例14: RGBLed

        public RGBLed(int redPin, int greenPin, int bluePin)
        {
            var gpio = GpioController.GetDefault();
            if (gpio == null) throw new RGBLedException(RGBLedError.E_GPIO_NOT_FOUND);

            try
            {
                m_redPin = gpio.OpenPin(redPin);
                m_greenPin = gpio.OpenPin(greenPin);
                m_bluePin = gpio.OpenPin(bluePin);

                m_redPin.Write(GpioPinValue.Low);
                m_redPin.SetDriveMode(GpioPinDriveMode.Output);

                m_greenPin.Write(GpioPinValue.Low);
                m_greenPin.SetDriveMode(GpioPinDriveMode.Output);

                m_bluePin.Write(GpioPinValue.Low);
                m_bluePin.SetDriveMode(GpioPinDriveMode.Output);

            }
            catch(Exception ex)
            {
                throw new RGBLedException(RGBLedError.E_OPEN_PIN_ERROR, ex);
            }
        }
开发者ID:TopTuK,项目名称:YaPiTraffic,代码行数:26,代码来源:RGBLed.cs

示例15: InitGPIO

        private void InitGPIO()
        {
            var gpio = GpioController.GetDefault();

            // Show an error if there is no GPIO controller
            if (gpio == null)
            {
                _buttonpin = null;
                _buzzerpin = null;
                GpioStatus.Text = "There is no GPIO controller on this device.";
                return;
            }

            _buttonpin = gpio.OpenPin(BUTTON_PIN);
            _buzzerpin = gpio.OpenPin(BUZZER_PIN);

            if (_buttonpin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp))
                _buttonpin.SetDriveMode(GpioPinDriveMode.InputPullUp);
            else
                _buttonpin.SetDriveMode(GpioPinDriveMode.Input);

            _buttonpin.DebounceTimeout = TimeSpan.FromMilliseconds(50);
            _buttonpin.ValueChanged += Buttonpin_ValueChanged;

            _buzzerpin.Write(GpioPinValue.Low);
            _buzzerpin.SetDriveMode(GpioPinDriveMode.Output);

            GpioStatus.Text = "GPIO button and buzzer pin initialized correctly.";
        }
开发者ID:nielsvdc,项目名称:raspberrypi-sunfounder,代码行数:29,代码来源:MainPage.xaml.cs


注:本文中的Windows.Devices.Gpio.GpioPin.Write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。