So I have a number picker to chose which pin to enable and a toggle button 
working with it to turn the pin selected via the number picker on and off; 
it's just a basic copypaste of the HELLOIOIO; however if you change the pin 
number the loop does not recognize it and the light will not go on for any 
other pins.

Thanks;

CODE:
public class MainActivity extends IOIOActivity {
private ToggleButton togglePin;
private NumberPicker chosePin;

/**
 * Called when the activity is first created. Here we normally initialize
 * our GUI.
 */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
togglePin = (ToggleButton) findViewById(R.id.togglePin);
chosePin = (NumberPicker) findViewById(R.id.numberPicker);
chosePin.setMaxValue(46);
chosePin.setMinValue(1);
}

/**
 * This is the thread on which all the IOIO activity happens. It will be run
 * every time the application is resumed and aborted when it is paused. The
 * method setup() will be called right after a connection with the IOIO has
 * been established (which might happen several times!). Then, loop() will
 * be called repetitively until the IOIO gets disconnected.
 */
class Looper extends BaseIOIOLooper {
/** The on-board LED. */
private DigitalOutput led_;
private DigitalOutput out;

/**
 * Called every time a connection with IOIO has been established.
 * Typically used to open pins.
 * 
 * @throws ConnectionLostException
 *             When IOIO connection is lost.
 * 
 * @see ioio.lib.util.AbstractIOIOActivity.IOIOThread#setup()
 */
@Override
protected void setup() throws ConnectionLostException {
out = ioio_.openDigitalOutput(chosePin.getValue());
}

/**
 * Called repetitively while the IOIO is connected.
 * 
 * @throws ConnectionLostException
 *             When IOIO connection is lost.
 * 
 * @see ioio.lib.util.AbstractIOIOActivity.IOIOThread#loop()
 */
@Override
public void loop() throws ConnectionLostException {
out.write(!togglePin.isChecked());
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
}

/**
 * A method to create our IOIO thread.
 * 
 * @see ioio.lib.util.AbstractIOIOActivity#createIOIOThread()
 */
@Override
protected IOIOLooper createIOIOLooper() {
return new Looper();
}
}

-- 
You received this message because you are subscribed to the Google Groups 
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to