1

An arstechnica.com article published today outlined Google's latest progress towards their IoT platform, Android Things (formerly Project Brillo). It looks like it supports the Pi 3.

Is it possible to access the Pi's GPIO pins from a native Android application? Can you provide a brief example?

4

You can access the GPIO pins using the new Peripheral I/O API.

Example for turning BCM6 pin to HIGH:

PeripheralManagerService pioService = new PeripheralManagerService();
Gpio pin = pioService.openGpio("BCM6");
gpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
// turn on.
gpio.setValue(true);
// turn off.
gpio.setValue(false);

Make sure to check the pinout for the Raspberry Pi 3 on the official doc or on pinout.xyz

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.