Skip to content

Most visited

Recently visited

navigation

Connect the Hardware

This lesson teaches you to

  1. Connect a button to GPIO
  2. Connect an LED to GPIO

You should also read

Before writing any code, you need to connect peripherals from your development kit to your board.

In this lesson, you will learn to wire a pushbutton switch and LED from a breadboard to your device. To connect the peripherals to your board:

  1. Connect one side of the button to the chosen GPIO input pin, and the other side to ground.
  2. Connect the same GPIO input pin to +3.3V through a pull-up resistor.
  3. Connect the chosen GPIO output pin to one side of a series resistor.
  4. Connect the other side of the resistor to the anode side (longer lead) of the LED.
  5. Connect the cathode side (shorter lead) of the LED to ground.

For this lesson, the following GPIO pins are assumed on each board:

Board Input Signal Output Signal
NXP Pico i.MX6UL GPIO4_IO20 GPIO4_IO21
NXP Pico i.MX7D GPIO2_IO07 GPIO2_IO02
Raspberry Pi BCM21 BCM6

""

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)