Overview
Nubsio is a Windows plug and play USB interface to connect your PC to the external world and control electronic devices with any .NET languages.
Nusbio offers:
- 8 digital Input/Output pins (or GPIO) with support of the SPI and I2C protocols
- 8 analog to digital pins (ADC, with the Analog or Sensor extension)
GPIO API
PinMode
By default the GPIO pins are initialized as output. To change the direction of an GPIO pin, use the following methods from the Nusbio class.public void SetPinMode(NusbioGpio pin, PinMode mode); public void SetPinMode(int pin, PinMode mode); // Sample var serialNumber = Nusbio.Detect(); using (var nusbio = new Nusbio(serialNumber: serialNumber)) { nusbio.SetPinMode(NusbioGpio.Gpio0, PinMode.Output); // Enum type syntax nusbio.SetPinMode(1, PinMode.InputPullUp); // Integer syntax }
The nusbio.GPIOS property allow to access the 8 GPIO pins using the following interface.
public interface GpioPublicApiBase { PinMode Mode { get; } string Name { get; } PinState PinState { get; } bool State { get; set; } PinState DigitalRead(); void DigitalWrite(PinState on); void DigitalWrite(bool high); void High(); void Low(); } // Sample var serialNumber = Nusbio.Detect(); using (var nusbio = new Nusbio(serialNumber: serialNumber)) { nusbio.SetPinMode(NusbioGpio.Gpio0, PinMode.Output); // Enum type syntax nusbio.SetPinMode(1, PinMode.InputPullUp); // Integer syntax // Turn gpio pin 0 on nusbio.GPIOS[NusbioGpio.Gpio0].DigitalWrite(PinState.High); nusbio.GPIOS[NusbioGpio.Gpio0].DigitalWrite(true); // Read the state for gpio 1 var state = nusbio[1].DigitalRead(); state = nusbio[1].DigitalReadDebounced(); }
Code Sample
For more information on using the GPIO pins in output mode see the following samples:- Nusbio.Console Source
Componentbuy is one of the fastest growing distributors of Semiconductors and electronic Components in the world.Supports more than 20 Millions of Electronic components sourcing needs with Engineering Data support. Locating all your required components for your design and production needs.
ReplyDeleteOur website will act as tool for the sourcing and Design engineers on the components needs.
componentbuy.com