private static string UID = "XYZ"; // Change XYZ to the UID of your IO-4 Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletIO4 io = new BrickletIO4(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current value as bitmask byte valueMask = io.GetValue(); Console.WriteLine("Value Mask: " + Convert.ToString(valueMask, 2)); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletIO4 io = new BrickletIO4(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Register interrupt callback to function InterruptCB io.Interrupt += InterruptCB; // Enable interrupt on pin 0 io.SetInterrupt(1 << 0); 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 #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletIO4 io = new BrickletIO4(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Set pin 1 to output low io.SetConfiguration(1 << 1, 'o', false); // Set pin 2 and 3 to output high io.SetConfiguration((1 << 2) | (1 << 3), 'o', true); 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 #endregion Fields #region Methods // Callback function for interrupt callback static void InterruptCB(BrickletIO4 sender, byte interruptMask, byte valueMask) { Console.WriteLine("Interrupt Mask: " + Convert.ToString(interruptMask, 2)); Console.WriteLine("Value Mask: " + Convert.ToString(valueMask, 2)); Console.WriteLine(""); }