CRTC Electronics

Click here to edit subtitle

Hello World

The Two Main Files    This is where all of our logic code is, (the code that does stuff)


main.xml   This is a layout of how all our buttons and information is shown (how things will look)

The Four Important Methods


  • onCreate() is called one time when your app is created
  • this is where we make a variable called button_ that links us to the toggle button

public void onCreate(Bundle savedInstanceState) 




   button_ = (ToggleButton) findViewById(; 




  • looper contains setup() and loop()
  • initialize your variables

class Looper extends BaseIOIOLooper 


   private DigitalOutput led_;



  • setup() is called every time a connection with IOIO has been established
  • variable led_ is an instance of openDigitalOutput
  • openDigitalOutput's first argument is the pin number (0 = on-board LED)
  • openDigitalOutput's second argument is the initial state of the pin 

protected void setup() throws ConnectionLostException 


   showVersions(ioio_, "IOIO connected!");

   led_ = ioio_.openDigitalOutput(0, true);




  • loop() is called repetitively while the IOIO is connected
  • here we are setting our led_ to the inverse of the button (on-board LED need a negative to turn on)

public void loop() throws ConnectionLostException, InterruptedException 







Turn a pin on and off

Use the toggle button to turn on and off a pin by making a second instance of openDigitalOutput and using a different pin.