Project name > res > layout > main.xml

Project name > src > Package name > Main.java

package app.inex.helloioio;

import ioio.lib.api.DigitalOutput;
import ioio.lib.api.exception.ConnectionLostException;
import ioio.lib.util.BaseIOIOLooper;
import ioio.lib.util.IOIOLooper;
import ioio.lib.util.android.IOIOActivity;
import android.os.Bundle;
import android.widget.Toast;
import android.widget.ToggleButton;

public class Main extends IOIOActivity {
private ToggleButton button_;

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 {
led_ = ioio_.openDigitalOutput(0, true);
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(),
“Connected!”, Toast.LENGTH_SHORT).show();
}
});
}

public void loop() throws ConnectionLostException {
led_.write(!button_.isChecked());
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
}

protected IOIOLooper createIOIOLooper() {
return new Looper();
}
}

สาเหตุ : เกิดการ error ตอนรันเข้าสู่ Run Configgurations…