int main(void) { // Create IP connection IPConnection ipcon; ipcon_create(&ipcon); // Create device object IndustrialQuadRelay iqr; industrial_quad_relay_create(&iqr, UID, &ipcon); // Connect to brickd if(ipcon_connect(&ipcon, HOST, PORT) < 0) { fprintf(stderr, "Could not connect\n"); return 1; } // Don't use device before ipcon is connected // Set pins to high for 1.5 seconds industrial_quad_relay_set_monoflop(&iqr, VALUE_A_ON, 15, 1500); ipcon_destroy(&ipcon); // Calls ipcon_disconnect internally return 0; }
int main() { // Create IP connection IPConnection ipcon; ipcon_create(&ipcon); // Create device object IndustrialQuadRelay iqr; industrial_quad_relay_create(&iqr, UID, &ipcon); // Connect to brickd if(ipcon_connect(&ipcon, HOST, PORT) < 0) { fprintf(stderr, "Could not connect\n"); exit(1); } // Don't use device before ipcon is connected // Turn relay 0, 3 on and relay 1, 2 off. industrial_quad_relay_set_value(&iqr, 1 | 8); printf("Press key to exit\n"); getchar(); ipcon_destroy(&ipcon); // Calls ipcon_disconnect internally }