Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Latest commit

 

History

History
53 lines (38 loc) · 1.83 KB

File metadata and controls

53 lines (38 loc) · 1.83 KB

Grove Button sample for Android Things using UPM

This example demonstrates a GPIO interrupts using UPM.

Pre-Requisites:

Use of the Grove Kit (for Joule or Edison) makes this easy. See the following links for getting a starter kit.

You will need:

  1. Android Things compatible board.
  2. Grove header or Breakout board.
  3. A Grove push button.

Build and install:

On Android Studio, select the "buttonintr" module in select box by the "Run" button and then click on the "Run" button.

Changing the GPIO pin

This example uses a GPIO (digital input) to read the state of a button. The GPIO could be connected via the shield to a Grove button... or it could be a button or wire on a breakout board directly connected between a GPIO line and Vcc.

The GPIO line to be used is specified in the strings.xml file (src/res/values directory).

<resources>
    <string name="app_name">ButtonIntr</string>

    <string name="Button_Edison_Arduino">IO0</string>
    <string name="Button_Edison_Sparkfun">GP20</string>
    <string name="Button_Joule_Tuchuck">J7_64</string>
</resources>

The code will automatically determine the board type being run on (modify BoardDefaults.java in the driver library to add another board) and select a string from this file for the GPIO line. The above example uses IO0 on the Edison Arduino shield and J7_64 on the Joule Tuchuck development board. These strings are programmed into the Peripheral Manager and read from their into the UPM library to determine the GPIO pin to be used.

See the top level README.md for a table describing the available GPIO pins and where to find them on the board.