C# example for using the DigitalInput and DigitalOutput device
10 public static void DigitalInputOutput()
24 digitalOutput.Open(0);
27 digitalInput.ConfigureDebounceTime(200, 200);
29 UInt32 NumberOfInputs = digitalInput.NumberOfInputs;
30 UInt32 NumberOfOutputs = digitalOutput.NumberOfOutputs;
31 Console.WriteLine(
"\nNumber of digital outputs: " + NumberOfOutputs.ToString() +
32 "\nNumber of digital inputs: " + NumberOfInputs.ToString());
35 digitalOutput.Output = 0xff;
36 System.Threading.Thread.Sleep(10);
38 Console.WriteLine(
"\nInput state: 0x" + digitalInput.Input.ToString(
"x"));
40 digitalOutput.SetBit(0,
false);
41 System.Threading.Thread.Sleep(10);
42 Console.WriteLine(
"\nInput state Bit 0: " + (digitalInput.GetBit(0) ?
"ON" :
"OFF"));
45 digitalOutput.Output = 0;
46 System.Threading.Thread.Sleep(10);
49 digitalInput.SensitivityMask = 0x3;
52 digitalOutput.SetBit(0,
true);
57 UInt32 inputEvent = digitalInput.WaitForInputEvent(1000);
58 Console.WriteLine(
"Input Event, new Input State: 0x" + inputEvent.ToString(
"x"));
60 catch (System.Exception)
62 Console.WriteLine(
"WaitForInputEvent: TimeOut");
66 digitalInput.AbortWaitingForInputEvent();
70 catch (System.Exception e)
72 Console.WriteLine(e.Message);
75 Console.WriteLine(
"\nPress enter to proceed...");
76 System.Console.ReadLine();