declare a variable as a digital input
*you may need to import ioio.api.Digitallnput (if DigitalInput shows an error Eclipse will suggest solutions, try choosing import.
private DigitalOutput led_;
private DigitalInput motionSensor_;
motionSensor_ = ioio_.openDigitalInput(7, Mode. PULL_DOWN );
read the pin and write it to the led
Use a Try/Catch statement
try
{
}
catch
{
}
try
{
led_.write( motionSensor_ .read());
//*
}
catch (InterruptedException e1)
{
e1.printStackTrace();
}
* if you want to change something on the screen when you receive an input you will need additional code to keep from crashing.