In this project we will use a as a notification when an obstacle is too close to our sensor. LED We will learn how the standard I/O works with a GPIO in Android Things. Requirements We use a with pre-installed (version 1). Raspberry Pi 3 Android Things Developer Preview I have a cheap and a for this project.You can use any LED what you want, I had only this at home. Obstacle Avoidance Sensor Dual-color Common Cathode LED Setup Google has a really good tutorial how to prepare your Raspberry Pi 3 for Android Things development, so I don’t want to describe it again. Please follow the steps here: _Raspberry Pi 3 Model B is the latest iteration of the world's most popular single board computer. It provides a quad…_developer.android.com Raspberry Pi 3 | Android Things Wiring So, let’s see our sensors. The has 4 pins, we use only 3 of them. The 4th (Null), the top one is not in use. Obstacle Avoidance Sensor As you see in the picture, the bottom one needs to be connected to a ( ) pin on the Pi, the obviously to a 5V power pin, and the pin needs to be connected to a GPIO. Ground GND 5V Digital Output The Digital Output pin sends the signals to our development board if an obstacle is too close. The LED module is a bit simpler. It has only 3 pins, we will use 2 of them, but of course, you can connect all the 3 to your Pi for testing. The connects to a Ground pin on your Pi, and the (or Green on some modules) and the input pins need to be connected to a GPIO (1 pin - 1 GPIO) on your board. (For this project one Input pin is enough to be connected.) GND Yellow Red (If you have a simple LED, you have only 2 pins, 1 Ground and 1 Input pin.) Here is how I connected the with the Raspberry Pi: Obstacle Avoidance Sensor pins → Null → GPIO 21 (BCM21, Pin 40) Digital Output → 5V (Pin 4) 5V → GND (Pin 20) GND And here is how the connect to the Pi: LED pins → GND (Pin 34) GND → GPIO 16 (BCM16, Pin 36) Yellow → GPIO 20 (BCM20, Pin 38) Red And this it how it looks together:(On the left side you can see a pinout diagram which illustrates the locations of the available ports exposed by the breakout connectors of the Raspberry Pi 3 board) Software Google also has a good tutorial how to configure your Android Things project in Android Studio. Please follow the steps here: _Things apps use the same structure as those designed for phones and tablets. This similarity means you can modify your…_developer.android.com Create an Android Things Project | Android Things Now you have a basic, compilable, working Android Things application, so we can start adding the necessary code. In our main Activity we can setup our GPIO pins: Then we initialize the pin ( ) for the as an (we read from this pin): BCM21 Obstacle Avoidance Sensor input Configure the LED pins ( , ) as an (we write to those pins): BCM16 BCM20 output And our , which does the magic: (blinks the led, when the obstacle is too close) GpioCallback() And don’t forget to if you don’t need them: close the resources That’s it! And the end result: I hope you enjoyed the Raspberry Pi hacking with Android. The full project is available on Github: _Contribute to AndroidThings-ObstacleAvoidanceSensor development by creating an account on GitHub._github.com Danesz/AndroidThings-ObstacleAvoidanceSensor