private static string UID = "XYZ"; // Change XYZ to the UID of your IO-4 Bricklet 2.0 // Callback function for input value callback static void InputValueCB(BrickletIO4V2 sender, byte channel, bool changed, bool value) { Console.WriteLine("Channel: " + channel); Console.WriteLine("Changed: " + changed); Console.WriteLine("Value: " + value); Console.WriteLine(""); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletIO4V2 io = new BrickletIO4V2(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Register input value callback to function InputValueCB io.InputValueCallback += InputValueCB; // Set period for input value (channel 1) callback to 0.5s (500ms) io.SetInputValueCallbackConfiguration(1, 500, false); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your IO-4 Bricklet 2.0 static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletIO4V2 io = new BrickletIO4V2(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current value bool[] value = io.GetValue(); Console.WriteLine("Channel 0: " + value[0]); Console.WriteLine("Channel 1: " + value[1]); Console.WriteLine("Channel 2: " + value[2]); Console.WriteLine("Channel 3: " + value[3]); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your IO-4 Bricklet 2.0 static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletIO4V2 io = new BrickletIO4V2(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Configure channel 3 as output low io.SetConfiguration(3, 'o', false); // Set channel 3 alternating high/low 10 times with 100 ms delay for (int i = 0; i < 10; i++) { Thread.Sleep(100); io.SetSelectedValue(3, true); Thread.Sleep(100); io.SetSelectedValue(3, false); } Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }