The Two Main Files
MainActivity.java This is where all of our logic code is, (the code that does stuff)
The Four Important Methods
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button_ = (ToggleButton) findViewById(R.id.button);
}
class Looper extends BaseIOIOLooper
{
private DigitalOutput led_;
...
protected void setup() throws ConnectionLostException
{
showVersions(ioio_, "IOIO connected!");
led_ = ioio_.openDigitalOutput(0, true);
enableUi(true);
}
public void loop() throws ConnectionLostException, InterruptedException
{
led_.write(!button_.isChecked());
Thread.sleep(100);
}
Use the toggle button to turn on and off a pin by making a second instance of openDigitalOutput and using a different pin.