Last active
October 11, 2016 15:51
-
-
Save madhephaestus/57daacd49104b305463a1f02c76d243d to your computer and use it in GitHub Desktop.
Arduino DyIo firmware loading and DyIo connection.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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