IO Port
This documentation includes installation guidelines and sample code for your hardware.
Windows 10 IoT Core Library
IOPort library is responsible for reading analog inputs and controlling GPIO pins on the IO Ports.
To use the library, add the following using statement to the top of your C# code.
Then, create an instance of the IOPort class.
Now you're ready to access the library by calling the ioPort instance.
Initialization
IOPort
Initiates the IO Port function to use GPIO and analog input functions.
Parameters
Bool d1In: Set true for input, false for output.
Bool d2In: Set true for input, false for output.
Bool d3In: Set true for input, false for output.
Bool d4In: Set true for input, false for output.
Basic Members
Write Pin State
Writes to digital pin.
Parameters
Int ch: Digital output channel. 1, 2, 3 or 4.
Bool st: True for high, false for low output state.
Returns
None
Read Pin State
Reads current digital pin input state.
Parameters
Int ch: Digital input channel. 1, 2, 3 or 4.
Returns
Bool: True if input is high. False if input is low.
Read Analog Input
Reads analog input value.
Parameters
Int ch: Analog input channel. 1, 2, 3 or 4.
Bool multipleRead: Performs multiple reads and returns average value.
Returns
Double: Analog read value, 0.0 to 1.0. 0 equals to 0V input and 1 equals to 3.3V input.
Interrupts
D1 Value Changed
Notifies on digital pin input change.
Event Args
Int Ch: IO Port GPIO pin numver. 1 to 4.
Bool State: GPIO Pin input state. True for logic high, false for logic low.
Disposal
To clean up the resources used by the class, call the Dispose() method it when the application is closing.
This method cleans the resources used by the class.
Samples
You can copy the example code from https://github.com/Turta-io/IoTHAT/tree/master/Samples/Windows10IoTCore address. There is one example of this library.
Analog In Sample App
This application demonstrates reading analog input from IO Port A1, A2, A3, and A4 channels.
To run the example:
Open the sample project you downloaded.
Make sure "ARM" is selected from the solution platforms selection.
Deploy the sample to the Raspberry Pi using the "F5" key.
Sample Code
Result
When you run the sample, it prints the analog input readings to the Visual Studio Output / Immediate Window.
To stop the application, use the "Stop" button on the Visual Studio.
Last updated