Skip to content

Instantly share code, notes, and snippets.

@madhephaestus
Last active October 11, 2016 15:51
Show Gist options
  • Save madhephaestus/57daacd49104b305463a1f02c76d243d to your computer and use it in GitHub Desktop.
Save madhephaestus/57daacd49104b305463a1f02c76d243d to your computer and use it in GitHub Desktop.
Arduino DyIo firmware loading and DyIo connection.
import com.neuronrobotics.sdk.dyio.DyIO;
import com.neuronrobotics.sdk.ui.ConnectionDialog;
ScriptingEngine.gitScriptRun(
"https://github.com/CommonWealthRobotics/BowlerCom.git", // git location of the library
"examples/DyIOLargeChip/DyIOLargeChip.ino" , // Arduino DyIo default firmware
null
);
System.out.println("Starting");
DyIO dyio=new DyIO();
if (!ConnectionDialog.getBowlerDevice(dyio)){
System.err.println("Dialog failed");
return;
}
dyio.ping();
System.out.println("Connection OK!");
// Set up channel 1 as an output
DigitalOutputChannel doc = new DigitalOutputChannel(dyio.getChannel(13));
// Blink the LED 5 times
for(int i = 0; i < 10; i++) {
System.out.println("Blinking.");
// Set the value high every other time, exit if unsuccessful
if(!doc.setHigh(i % 2 == 1)) {
System.err.println("Could not connect to the device.");
System.exit(0);
}
// pause between cycles so that the changes are visible
Thread.sleep(1000);
}
dyio.setScriptingName("dyio")
return dyio;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment