private static string UID = "XYZ"; // Change XYZ to the UID of your Multi Touch Bricklet 2.0 static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletMultiTouchV2 mt = new BrickletMultiTouchV2(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current touch state bool[] state = mt.GetTouchState(); Console.WriteLine("Electrode 0: " + state[0]); Console.WriteLine("Electrode 1: " + state[1]); Console.WriteLine("Electrode 2: " + state[2]); Console.WriteLine("Electrode 3: " + state[3]); Console.WriteLine("Electrode 4: " + state[4]); Console.WriteLine("Electrode 5: " + state[5]); Console.WriteLine("Electrode 6: " + state[6]); Console.WriteLine("Electrode 7: " + state[7]); Console.WriteLine("Electrode 8: " + state[8]); Console.WriteLine("Electrode 9: " + state[9]); Console.WriteLine("Electrode 10: " + state[10]); Console.WriteLine("Electrode 11: " + state[11]); Console.WriteLine("Proximity: " + state[12]); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletDCV2 dc = new BrickletDCV2(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // The acceleration has to be smaller or equal to the maximum // acceleration of the DC motor, otherwise the velocity reached // callback will be called too early dc.SetMotion(4096, 16384); // Slow acceleration (12.5 %/s), fast decceleration (50 %/s) for stopping dc.SetVelocity(32767); // Full speed forward (100 %) // Register velocity reached callback to function VelocityReachedCB dc.VelocityReachedCallback += VelocityReachedCB; // Enable motor power dc.SetEnabled(true); Console.WriteLine("Press enter to exit"); Console.ReadLine(); dc.SetVelocity(0); // Stop motor before disabling motor power Thread.Sleep(2000); // Wait for motor to actually stop: velocity (100 %) / decceleration (50 %/s) = 2 s dc.SetEnabled(false); // Disable motor power ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletOLED64x48 oled = new BrickletOLED64x48(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Clear display oled.ClearDisplay(); // Draw checkerboard pattern bool[][] pixels = new bool[HEIGHT][]; for (int row = 0; row < HEIGHT; row++) { pixels[row] = new bool[WIDTH]; for (int column = 0; column < WIDTH; column++) { pixels[row][column] = (row / 8) % 2 == (column / 8) % 2; } } DrawMatrix(oled, pixels); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletRS485 rs485 = new BrickletRS485(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Enable full-duplex mode rs485.SetRS485Configuration(115200, BrickletRS485.PARITY_NONE, BrickletRS485.STOPBITS_1, BrickletRS485.WORDLENGTH_8, BrickletRS485.DUPLEX_FULL); // Register read callback to function ReadCB rs485.ReadCallback += ReadCB; // Enable read callback rs485.EnableReadCallback(); // Write "test" string rs485.Write("test".ToCharArray()); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletLaserRangeFinderV2 lrf = new BrickletLaserRangeFinderV2(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Turn laser on and wait 250ms for very first measurement to be ready lrf.SetEnable(true); Thread.Sleep(250); // Register distance callback to function DistanceCB lrf.DistanceCallback += DistanceCB; // Configure threshold for distance "greater than 20 cm" // with a debounce period of 1s (1000ms) lrf.SetDistanceCallbackConfiguration(1000, false, '>', 20, 0); Console.WriteLine("Press enter to exit"); Console.ReadLine(); // Turn laser off lrf.SetEnable(false); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletLaserRangeFinder lrf = new BrickletLaserRangeFinder(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Turn laser on and wait 250ms for very first measurement to be ready lrf.EnableLaser(); Thread.Sleep(250); // Get threshold callbacks with a debounce time of 10 seconds (10000ms) lrf.SetDebouncePeriod(10000); // Register distance reached callback to function DistanceReachedCB lrf.DistanceReachedCallback += DistanceReachedCB; // Configure threshold for distance "greater than 20 cm" (unit is cm) lrf.SetDistanceCallbackThreshold('>', 20, 0); Console.WriteLine("Press enter to exit"); Console.ReadLine(); lrf.DisableLaser(); // Turn laser off ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Industrial Quad Relay Bricklet static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletIndustrialQuadRelay iqr = new BrickletIndustrialQuadRelay(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Turn relays alternating on/off 10 times with 100 ms delay for (int i = 0; i < 10; i++) { Thread.Sleep(100); iqr.SetValue(1 << 0); Thread.Sleep(100); iqr.SetValue(1 << 1); Thread.Sleep(100); iqr.SetValue(1 << 2); Thread.Sleep(100); iqr.SetValue(1 << 3); } Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletServoV2 s = new BrickletServoV2(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Register position reached callback to function PositionReachedCB s.PositionReachedCallback += PositionReachedCB; // Enable position reached callback s.SetPositionReachedCallbackConfiguration(0, true); // Set velocity to 100°/s. This has to be smaller or equal to the // maximum velocity of the servo you are using, otherwise the position // reached callback will be called too early s.SetMotionConfiguration(0, 10000, 500000, 500000); s.SetPosition(0, 9000); s.SetEnable(0, true); Console.WriteLine("Press enter to exit"); Console.ReadLine(); s.SetEnable(0, false); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletRS485 rs485 = new BrickletRS485(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Set operating mode to Modbus RTU master rs485.SetMode(BrickletRS485.MODE_MODBUS_MASTER_RTU); // Modbus specific configuration: // - slave address = 1 (unused in master mode) // - master request timeout = 1000ms rs485.SetModbusConfiguration(1, 1000); // Register Modbus master write single register response callback to function // ModbusMasterWriteSingleRegisterResponseCB rs485.ModbusMasterWriteSingleRegisterResponseCallback += ModbusMasterWriteSingleRegisterResponseCB; // Write 65535 to register 42 of slave 17 expectedRequestID = rs485.ModbusMasterWriteSingleRegister(17, 42, 65535); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Real-Time Clock Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletRealTimeClock rtc = new BrickletRealTimeClock(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current date and time int year; byte month, day, hour, minute, second, centisecond, weekday; rtc.GetDateTime(out year, out month, out day, out hour, out minute, out second, out centisecond, out weekday); Console.WriteLine("Year: " + year); Console.WriteLine("Month: " + month); Console.WriteLine("Day: " + day); Console.WriteLine("Hour: " + hour); Console.WriteLine("Minute: " + minute); Console.WriteLine("Second: " + second); Console.WriteLine("Centisecond: " + centisecond); Console.WriteLine("Weekday: " + weekday); // Get current timestamp (unit is ms) long timestamp = rtc.GetTimestamp(); Console.WriteLine("Timestamp: " + timestamp + " ms"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletEPaper296x128 epaper = new BrickletEPaper296x128(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Download example image here: // https://raw.githubusercontent.com/Tinkerforge/e-paper-296x128-bricklet/master/software/examples/tf_red.png Bitmap bitmap = new Bitmap("tf_red.png"); // Get black/white pixels from image and write them to the Bricklet buffer bool[] pixelsBW = BoolArrayFromImage(bitmap, Color.White); epaper.WriteBlackWhite(0, (byte)0, WIDTH - 1, (byte)(HEIGHT - 1), pixelsBW); // Get red pixels from image and write them to the Bricklet buffer bool[] pixelsRed = BoolArrayFromImage(bitmap, Color.Red); epaper.WriteColor(0, (byte)0, WIDTH - 1, (byte)(HEIGHT - 1), pixelsRed); // Draw buffered values to the display epaper.Draw(); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static void Main() { double setPoint = 130; IPConnection ipcon = new IPConnection(); // Create IP connection ipcon.Connect(HOST, PORT); // Connect to brickd var light = new BrickletAmbientLight(UidAmbientLight, ipcon); ledStrip = new BrickletLEDStrip(UidLedStrip, ipcon); var pid = new PidCompute(0.3, 0.00001, 0); ledStrip.SetChannelMapping(6); var ledHandler = new LedHanlder(ledStrip); while (true) { var lux = light.GetIlluminance(); Console.Out.WriteLine($"Lux: {lux}"); var res = pid.Compute(setPoint, lux); Console.Out.WriteLine($"PID Result: {res}"); ledHandler.SetLedStrip(res); Thread.Sleep(20); } Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletOLED128x64V2 oled = new BrickletOLED128x64V2(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Clear display oled.ClearDisplay(); // Draw checkerboard pattern bool[] pixels = new bool[HEIGHT * WIDTH]; for (int row = 0; row < HEIGHT; row++) { for (int column = 0; column < WIDTH; column++) { pixels[row * WIDTH + column] = (row / 8) % 2 == (column / 8) % 2; } } oled.WritePixels(0, 0, (byte)(WIDTH - 1), (byte)(HEIGHT - 1), pixels); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Laser Range Finder Bricklet 2.0 static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletLaserRangeFinderV2 lrf = new BrickletLaserRangeFinderV2(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Turn laser on and wait 250ms for very first measurement to be ready lrf.SetEnable(true); Thread.Sleep(250); // Get current distance short distance = lrf.GetDistance(); Console.WriteLine("Distance: " + distance + " cm"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); // Turn laser off lrf.SetEnable(false); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Segment Display 4x7 Bricklet 2.0 static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletSegmentDisplay4x7V2 sd = new BrickletSegmentDisplay4x7V2(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected sd.SetBrightness(7); // Set to full brightness // Blink colon 10 times for (int i = 0; i < 10; i++) { // Activate segments of colon sd.SetSelectedSegment(32, true); sd.SetSelectedSegment(33, true); Thread.Sleep(250); // Deactivate segments of colon sd.SetSelectedSegment(32, false); sd.SetSelectedSegment(33, false); } Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Industrial Digital Out 4 Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletIndustrialDigitalOut4 ido4 = new BrickletIndustrialDigitalOut4(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Turn pins alternating high/low 10 times with 100ms delay for(int i = 0; i < 10; i++) { Thread.Sleep(100); ido4.SetValue(1 << 0); Thread.Sleep(100); ido4.SetValue(1 << 1); Thread.Sleep(100); ido4.SetValue(1 << 2); Thread.Sleep(100); ido4.SetValue(1 << 3); } Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your UV Light Bricklet 2.0 static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletUVLightV2 uvl = new BrickletUVLightV2(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current UV-A int uva = uvl.GetUVA(); Console.WriteLine("UV-A: " + uva / 10.0 + " mW/m²"); // Get current UV-B int uvb = uvl.GetUVB(); Console.WriteLine("UV-B: " + uvb / 10.0 + " mW/m²"); // Get current UV index int uvi = uvl.GetUVI(); Console.WriteLine("UV Index: " + uvi / 10.0); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Energy Monitor Bricklet static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletEnergyMonitor em = new BrickletEnergyMonitor(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current energy data int voltage, current, energy, realPower, apparentPower, reactivePower, powerFactor, frequency; em.GetEnergyData(out voltage, out current, out energy, out realPower, out apparentPower, out reactivePower, out powerFactor, out frequency); Console.WriteLine("Voltage: " + voltage / 100.0 + " V"); Console.WriteLine("Current: " + current / 100.0 + " A"); Console.WriteLine("Energy: " + energy / 100.0 + " Wh"); Console.WriteLine("Real Power: " + realPower / 100.0 + " h"); Console.WriteLine("Apparent Power: " + apparentPower / 100.0 + " VA"); Console.WriteLine("Reactive Power: " + reactivePower / 100.0 + " var"); Console.WriteLine("Power Factor: " + powerFactor / 1000.0); Console.WriteLine("Frequency: " + frequency / 100.0 + " Hz"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Multi Touch Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletMultiTouch mt = new BrickletMultiTouch(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current touch state int state = mt.GetTouchState(); string str = ""; if((state & (1 << 12)) == (1 << 12)) { str += "In proximity, "; } if((state & 0xfff) == 0) { str += "No electrodes touched"; } else { str += "Electrodes "; for(int i = 0; i < 12; i++) { if((state & (1 << i)) == (1 << i)) { str += i + " "; } } str += "touched"; } Console.WriteLine(str); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Tilt Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletTilt t = new BrickletTilt(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current tilt state byte state = t.GetTiltState(); switch(state) { case BrickletTilt.TILT_STATE_CLOSED: Console.WriteLine("Tilt State: Closed"); break; case BrickletTilt.TILT_STATE_OPEN: Console.WriteLine("Tilt State: Open"); break; case BrickletTilt.TILT_STATE_CLOSED_VIBRATING: Console.WriteLine("Tilt State: Closed Vibrating"); break; } Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletCAN can = new BrickletCAN(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Configure transceiver for loopback mode can.SetConfiguration(BrickletCAN.BAUD_RATE_1000KBPS, BrickletCAN.TRANSCEIVER_MODE_LOOPBACK, 0); // Register frame read callback to function FrameReadCB can.FrameRead += FrameReadCB; // Enable frame read callback can.EnableFrameReadCallback(); // Write standard data frame with identifier 1742 and 3 bytes of data byte[] data = new byte[8]{42, 23, 17, 0, 0, 0, 0, 0}; can.WriteFrame(BrickletCAN.FRAME_TYPE_STANDARD_DATA, 1742, data, 3); Console.WriteLine("Press enter to exit"); Console.ReadLine(); can.DisableFrameReadCallback(); ipcon.Disconnect(); }
private static string UID = "XXYYZZ"; // Change XXYYZZ to the UID of your Servo Brick #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickServo servo = new BrickServo(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Register position reached callback to function PositionReachedCB servo.PositionReached += PositionReachedCB; // Enable position reached callback servo.EnablePositionReachedCallback(); // Set velocity to 100°/s. This has to be smaller or equal to the // maximum velocity of the servo you are using, otherwise the position // reached callback will be called too early servo.SetVelocity(0, 10000); servo.SetPosition(0, 9000); servo.Enable(0); Console.WriteLine("Press enter to exit"); Console.ReadLine(); servo.Disable(0); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your IO-16 Bricklet 2.0 static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletIO16V2 io = new BrickletIO16V2(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 [A0]: " + value[0]); Console.WriteLine("Channel 1 [A1]: " + value[1]); Console.WriteLine("Channel 2 [A2]: " + value[2]); Console.WriteLine("Channel 3 [A3]: " + value[3]); Console.WriteLine("Channel 4 [A4]: " + value[4]); Console.WriteLine("Channel 5 [A5]: " + value[5]); Console.WriteLine("Channel 6 [A6]: " + value[6]); Console.WriteLine("Channel 7 [A7]: " + value[7]); Console.WriteLine("Channel 8 [B0]: " + value[8]); Console.WriteLine("Channel 9 [B1]: " + value[9]); Console.WriteLine("Channel 10 [B2]: " + value[10]); Console.WriteLine("Channel 11 [B3]: " + value[11]); Console.WriteLine("Channel 12 [B4]: " + value[12]); Console.WriteLine("Channel 13 [B5]: " + value[13]); Console.WriteLine("Channel 14 [B6]: " + value[14]); Console.WriteLine("Channel 15 [B7]: " + value[15]); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Performance DC Bricklet static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletPerformanceDC pdc = new BrickletPerformanceDC(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected pdc.SetDriveMode(BrickletPerformanceDC.DRIVE_MODE_DRIVE_COAST); pdc.SetPWMFrequency(10000); // Use PWM frequency of 10 kHz pdc.SetMotion(4096, 4096); // Slow ac-/deceleration (12.5 %/s) pdc.SetVelocity(32767); // Full speed forward (100 %) pdc.SetEnabled(true); // Enable motor power Console.WriteLine("Press enter to exit"); Console.ReadLine(); // Stop motor before disabling motor power pdc.SetMotion(4096, 16384); // Fast decceleration (50 %/s) for stopping pdc.SetVelocity(0); // Request motor stop Thread.Sleep(2000); // Wait for motor to actually stop: velocity (100 %) / decceleration (50 %/s) = 2 s pdc.SetEnabled(false); // Disable motor power ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletCANV2 can = new BrickletCANV2(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Configure transceiver for loopback mode can.SetTransceiverConfiguration(1000000, 625, BrickletCANV2.TRANSCEIVER_MODE_LOOPBACK); // Register frame read callback to function FrameReadCB can.FrameReadCallback += FrameReadCB; // Enable frame read callback can.SetFrameReadCallbackConfiguration(true); // Write standard data frame with identifier 1742 and 3 bytes of data can.WriteFrame(BrickletCANV2.FRAME_TYPE_STANDARD_DATA, 1742, new byte[] { 42, 23, 17 }); Console.WriteLine("Press enter to exit"); Console.ReadLine(); can.SetFrameReadCallbackConfiguration(false); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Industrial Digital Out 4 Bricklet 2.0 static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletIndustrialDigitalOut4V2 ido4 = new BrickletIndustrialDigitalOut4V2(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Set channels alternating high/low 10 times with 100 ms delay for (int i = 0; i < 10; i++) { Thread.Sleep(100); ido4.SetValue(new bool[] { true, false, false, false }); Thread.Sleep(100); ido4.SetValue(new bool[] { false, true, false, false }); Thread.Sleep(100); ido4.SetValue(new bool[] { false, false, true, false }); Thread.Sleep(100); ido4.SetValue(new bool[] { false, false, false, true }); } Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletLaserRangeFinder lrf = new BrickletLaserRangeFinder(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Turn laser on and wait 250ms for very first measurement to be ready lrf.EnableLaser(); Thread.Sleep(250); // Register distance callback to function DistanceCB lrf.DistanceCallback += DistanceCB; // Set period for distance callback to 0.2s (200ms) // Note: The distance callback is only called every 0.2 seconds // if the distance has changed since the last call! lrf.SetDistanceCallbackPeriod(200); Console.WriteLine("Press enter to exit"); Console.ReadLine(); lrf.DisableLaser(); // Turn laser off ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Real-Time Clock Bricklet 2.0 static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletRealTimeClockV2 rtc = new BrickletRealTimeClockV2(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current date and time int year; byte month, day, hour, minute, second, centisecond, weekday; long timestamp; rtc.GetDateTime(out year, out month, out day, out hour, out minute, out second, out centisecond, out weekday, out timestamp); Console.WriteLine("Year: " + year); Console.WriteLine("Month: " + month); Console.WriteLine("Day: " + day); Console.WriteLine("Hour: " + hour); Console.WriteLine("Minute: " + minute); Console.WriteLine("Second: " + second); Console.WriteLine("Centisecond: " + centisecond); if (weekday == BrickletRealTimeClockV2.WEEKDAY_MONDAY) { Console.WriteLine("Weekday: Monday"); } else if (weekday == BrickletRealTimeClockV2.WEEKDAY_TUESDAY) { Console.WriteLine("Weekday: Tuesday"); } else if (weekday == BrickletRealTimeClockV2.WEEKDAY_WEDNESDAY) { Console.WriteLine("Weekday: Wednesday"); } else if (weekday == BrickletRealTimeClockV2.WEEKDAY_THURSDAY) { Console.WriteLine("Weekday: Thursday"); } else if (weekday == BrickletRealTimeClockV2.WEEKDAY_FRIDAY) { Console.WriteLine("Weekday: Friday"); } else if (weekday == BrickletRealTimeClockV2.WEEKDAY_SATURDAY) { Console.WriteLine("Weekday: Saturday"); } else if (weekday == BrickletRealTimeClockV2.WEEKDAY_SUNDAY) { Console.WriteLine("Weekday: Sunday"); } Console.WriteLine("Timestamp: " + timestamp + " ms"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static void Main() { double setPoint = 400; IPConnection ipcon = new IPConnection(); // Create IP connection ipcon.Connect(HOST, PORT); // Connect to brickd var display = new BrickletLCD20x4(UidLcdDisplay, ipcon); var displayPID = new BrickletLCD20x4(UidLcdDisplayPID, ipcon); var light = new BrickletAmbientLight(UidAmbientLight, ipcon); ledStrip = new BrickletLEDStrip(UidLedStrip, ipcon); var pid = new PidCompute(0.3, 0.0001, 0.0000003); ledStrip.SetChannelMapping(6); var rotaryPotiP = new BrickletRotaryPoti(UiWheelP, ipcon); var rotaryPotiI = new BrickletRotaryPoti(UiWheelI, ipcon); var rotaryPotiD = new BrickletRotaryPoti(UiWheelD, ipcon); var linerPoti = new BrickletLinearPoti("bxu", ipcon); display.BacklightOn(); displayPID.BacklightOn(); var ledHandler = new LedHanlder(ledStrip); double P = 0.15; double I = 0.15; double D = 0.15; while (true) { P = rotaryPotiP.GetAnalogValue() / 100000.0; I = rotaryPotiI.GetAnalogValue() / 1000000.0; D = rotaryPotiD.GetAnalogValue() / 1000000.0; setPoint = linerPoti.GetAnalogValue() / 10; pid = new PidCompute(P, I, D); Console.WriteLine("Goal: " + setPoint); var lux = light.GetIlluminance(); Console.Out.WriteLine($"Lux: {lux}"); var res = 0.1 * pid.Compute(setPoint, lux); Console.Out.WriteLine($"PID Result: {res}"); ledHandler.SetLedStrip(res); display.ClearDisplay(); displayPID.ClearDisplay(); display.WriteLine(0, 0, $"Setpoint: {setPoint}"); display.WriteLine(1, 0, $"Lux: {lux}"); display.WriteLine(2, 0, $"PID Result: {res}"); displayPID.WriteLine(0, 0, $"P: {P}"); displayPID.WriteLine(1, 0, $"I: {I}"); displayPID.WriteLine(2, 0, $"D: {D}"); Thread.Sleep(10); } Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private void DisconnectWorker_DoWork(object sender, DoWorkEventArgs e) { try { ipcon.Disconnect(); e.Result = true; } catch (NotConnectedException) { e.Result = false; } }
private static int VALUE_B_OFF = (1 << 1) | (1 << 3); // Pin 1 and 3 high static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletIndustrialQuadRelay iqr = new BrickletIndustrialQuadRelay(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected iqr.SetMonoflop(VALUE_A_ON, 15, 1500); // Set pins to high for 1.5 seconds ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletIndustrialQuadRelayV2 iqr = new BrickletIndustrialQuadRelayV2(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected AOn(iqr); ipcon.Disconnect(); }
static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletLCD128x64 lcd = new BrickletLCD128x64(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Register GUI button pressed callback to function GUIButtonPressedCB lcd.GUIButtonPressedCallback += GUIButtonPressedCB; // Register GUI slider value callback to function GUISliderValueCB lcd.GUISliderValueCallback += GUISliderValueCB; // Register GUI tab selected callback to function GUITabSelectedCB lcd.GUITabSelectedCallback += GUITabSelectedCB; // Clear display lcd.ClearDisplay(); lcd.RemoveAllGUI(); // Add GUI elements: Button, Slider and Graph with 60 data points lcd.SetGUIButton(0, 0, 0, 60, 20, "button"); lcd.SetGUISlider(0, 0, 30, 60, BrickletLCD128x64.DIRECTION_HORIZONTAL, 50); lcd.SetGUIGraphConfiguration(0, BrickletLCD128x64.GRAPH_TYPE_LINE, 62, 0, 60, 52, "X", "Y"); // Add a few data points (the remaining points will be 0) lcd.SetGUIGraphData(0, new byte[] { 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240 }); // Add 5 text tabs without and configure it for click and swipe without auto-redraw lcd.SetGUITabConfiguration(BrickletLCD128x64.CHANGE_TAB_ON_CLICK_AND_SWIPE, false); lcd.SetGUITabText(0, "Tab A"); lcd.SetGUITabText(1, "Tab B"); lcd.SetGUITabText(2, "Tab C"); lcd.SetGUITabText(3, "Tab D"); lcd.SetGUITabText(4, "Tab E"); // Set period for GUI button pressed callback to 0.1s (100ms) lcd.SetGUIButtonPressedCallbackConfiguration(100, true); // Set period for GUI slider value callback to 0.1s (100ms) lcd.SetGUISliderValueCallbackConfiguration(100, true); // Set period for GUI tab selected callback to 0.1s (100ms) lcd.SetGUITabSelectedCallbackConfiguration(100, true); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static int VALUE_B_ON = (1 << 1) | (1 << 2); // Pin 1 and 2 high #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletIndustrialQuadRelay iqr = new BrickletIndustrialQuadRelay(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected iqr.SetMonoflop(VALUE_A_ON, 15, 1500); // Set pins to high for 1.5 seconds ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your TNG DO8 static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection TNGDO8 do8 = new TNGDO8(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected do8.SetValues(0, new bool[] { true, false, true, false, true, false, true, false }); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
0x39, 0x5e, 0x79, 0x71 };// 0~9,A,b,C,d,E,F /// <summary> /// Anzeigen des Wertes am 7-Segment-Display /// </summary> /// <param name="value">Maximal 4 Stellen, nur Ganzzahlen</param> internal static void DisplayValue(string value) { try { int i3 = 0; int i2 = 0; int i1 = 0; int i0 = 0; int sl = value.Length; switch (sl) { case 1: i0 = Convert.ToInt32(value[0]); break; case 2: i1 = Convert.ToInt32(value[0].ToString()); i0 = Convert.ToInt32(value[1].ToString()); break; case 3: i2 = Convert.ToInt32(value[0].ToString()); i1 = Convert.ToInt32(value[1].ToString()); i0 = Convert.ToInt32(value[2].ToString()); break; case 4: i3 = Convert.ToInt32(value[0].ToString()); i2 = Convert.ToInt32(value[1].ToString()); i1 = Convert.ToInt32(value[2].ToString()); i0 = Convert.ToInt32(value[3].ToString()); break; } //int i3 = Convert.ToInt32(value[3]), i2 = Convert.ToInt32(value[2]), i1 = Convert.ToInt32( value[1]), i0 = Convert.ToInt32(value[0]); IPConnection ipcon = new IPConnection(); // Create IP connection BrickletSegmentDisplay4x7 sd = new BrickletSegmentDisplay4x7(UID_SD7, ipcon); // Create device object ipcon.Connect(HOST, PORT); byte[] segments = { DIGITS[i3], DIGITS[i2], DIGITS[i1], DIGITS[i0] }; sd.SetSegments(segments, 7, false); ipcon.Disconnect(); } catch (Exception ex) { throw new Exception("Fehler beim Anzeigen des Wertes", ex); } }
private static string UID = "XYZ"; // Change XYZ to the UID of your LED Strip Bricklet 2.0 static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletLEDStripV2 ls = new BrickletLEDStripV2(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Set first 3 LEDs to red, green and blue ls.SetLEDValues(0, new byte[] { 255, 0, 0, 0, 255, 0, 0, 0, 255 }); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Piezo Buzzer Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletPiezoBuzzer pb = new BrickletPiezoBuzzer(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Make 2 second beep pb.Beep(2000); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Dual Button Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletDualButton db = new BrickletDualButton(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Register state changed callback to function StateChangedCB db.StateChanged += StateChangedCB; Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Piezo Speaker Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletPiezoSpeaker ps = new BrickletPiezoSpeaker(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Morse SOS with a frequency of 2kHz ps.MorseCode("... --- ...", 2000); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Piezo Buzzer Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletPiezoBuzzer pb = new BrickletPiezoBuzzer(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Morse SOS pb.MorseCode("... --- ..."); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your RGB LED Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletRGBLED rl = new BrickletRGBLED(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Set light blue color rl.SetRGBValue(0, 170, 234); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Multi Touch Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletMultiTouch mt = new BrickletMultiTouch(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Register touch state callback to function TouchStateCB mt.TouchState += TouchStateCB; Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Analog Out Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletAnalogOut ao = new BrickletAnalogOut(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Set output voltage to 3.3V ao.SetVoltage(3300); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Voltage Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletVoltage v = new BrickletVoltage(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current voltage (unit is mV) int voltage = v.GetVoltage(); Console.WriteLine("Voltage: " + voltage/1000.0 + " V"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Moisture Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletMoisture m = new BrickletMoisture(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current moisture value int moisture = m.GetMoistureValue(); Console.WriteLine("Moisture Value: " + moisture); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Distance IR Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletDistanceIR dir = new BrickletDistanceIR(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current distance (unit is mm) int distance = dir.GetDistance(); Console.WriteLine("Distance: " + distance/10.0 + " cm"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Pressure Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletPressure p = new BrickletPressure(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current pressure (unit is Pa) int pressure = p.GetPressure(); Console.WriteLine("Pressure: " + pressure/1000.0 + " kPa"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Linear Poti Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletLinearPoti lp = new BrickletLinearPoti(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current position (range is 0 to 100) int position = lp.GetPosition(); Console.WriteLine("Position: " + position); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Thermocouple Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletThermocouple t = new BrickletThermocouple(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current temperature (unit is °C/100) int temperature = t.GetTemperature(); Console.WriteLine("Temperature: " + temperature/100.0 + " °C"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Current25 Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletCurrent25 c = new BrickletCurrent25(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current current (unit is mA) short current = c.GetCurrent(); Console.WriteLine("Current: " + current/1000.0 + " A"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Heart Rate Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletHeartRate hr = new BrickletHeartRate(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current heart rate (unit is bpm) int heartRate = hr.GetHeartRate(); Console.WriteLine("Heart Rate: " + heartRate + " bpm"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Line Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletLine l = new BrickletLine(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current reflectivity int reflectivity = l.GetReflectivity(); Console.WriteLine("Reflectivity: " + reflectivity); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Ambient Light Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletAmbientLight al = new BrickletAmbientLight(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current illuminance (unit is Lux/10) int illuminance = al.GetIlluminance(); Console.WriteLine("Illuminance: " + illuminance/10.0 + " Lux"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
static void Main() { // Create connection and connect to brickd IPConnection ipcon = new IPConnection(); ipcon.Connect(HOST, PORT); // Register Enumerate Callback ipcon.EnumerateCallback += EnumerateCB; // Trigger Enumerate ipcon.Enumerate(); System.Console.WriteLine("Press key to exit"); System.Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Sound Intensity Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletSoundIntensity si = new BrickletSoundIntensity(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current intensity int intensity = si.GetIntensity(); Console.WriteLine("Intensity: " + intensity); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Rotary Encoder Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletRotaryEncoder re = new BrickletRotaryEncoder(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current count without reset int count = re.GetCount(false); Console.WriteLine("Count: " + count); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your Distance US Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletDistanceUS dus = new BrickletDistanceUS(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current distance value int distance = dus.GetDistanceValue(); Console.WriteLine("Distance Value: " + distance); 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 // 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(); }
private static string UID = "XYZ"; // Change XYZ to the UID of your UV Light Bricklet #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickletUVLight uvl = new BrickletUVLight(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current UV light (unit is µW/cm²) long uvLight = uvl.GetUVLight(); Console.WriteLine("UV Light: " + uvLight + " µW/cm²"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }