Language - C Sharp Windows Visual Studio
C# Development Environments | ||||
---|---|---|---|---|
Windows | ||||
macOS | ||||
Linux |
Language - C# Windows with Visual Studio Welcome to using Phidgets with C#! By using C#, you will have access to the complete Phidget22 API, including events. Visual Studio is an IDE provided by Microsoft that can be used to develop code in a wide variety of programming languages, including C#. |
Install Phidget Drivers for Windows
Before getting started with the guides below, ensure you have the following components installed on your machine:
- You will need the Phidgets Windows Drivers
Use Our Examples
One of the best ways to start programming with Phidgets is to use our example code as a guide. In order to run the examples, you will need to download and install Microsoft Visual Studio.
Now that you have Microsoft Visual Studio installed, select an example that will work with your Phidget:
Open the example project and start the example by pressing the Start button:
The application will open the Phidget, list basic information about the Phidget, and demonstrate the Phidget's functionality. Here is an example of a Digital Output channel on a RFID Phidget:
You should now have the example up and running for your device. Play around with the device and experiment with some of the functionality. When you are ready, the next step is configuring your project and writing your own code!
VINT Hub
If you are trying to connect to one of the VINT hub ports directly rather than to a VINT device connected through a VINT hub then there is one additional step. There is a isHubPort property of the Phidget class that must be set before calling open. It defaults to false but in this case it will need to be set to true. In our examples this is done via command line though in practice you can just set it before calling open. To add command line parameters to your project in Visual Studio, you can go to the Project->Properties screen. Under the Debug section there is a field to enter command line parameters for startup. Use "-h" to make sure isHubPort is set before open is called and then you should be good to go.
Configure Your Project
When you are building a project from scratch, or adding Phidget functionality to an existing project, you'll need to configure your development environment to properly link the Phidget .NET library. To begin:
Create a new Windows Forms Application project:
Next, right-click to add a reference to the Phidget .NET library:
On the following screen, click Browse... and navigate to the location of Phidget22.NET.dll:
- C:\Program Files\Phidgets\Phidget22\Phidget22.NET.dll
Finally, to include the Phidget .NET library, add the following lines to main window class file:
using Phidget22;
using Phidget22.Events;
Success! The project now has access to Phidgets. Next, view the write your own code section located below.