If you are having issues with the exercises, please create a ticket on DevZone:
Click or drag files to this area to upload. You can upload up to 2 files.

Lesson 2 – Reading buttons and controlling LEDs


In this lesson, we will examine how hardware is described in nRF Connect SDK, whether it is a development kit (DK), a System on Chip (SoC), a System in a Package (SiP) or a module. Interaction between applications and hardware is done through pieces of software called device drivers, and we will explain the device driver model used in nRF Connect SDK. We will use the General-Purpose Input/Output (GPIO) hardware peripheral and driver as a case study. We will do a line-by-line walkthrough of the blinky sample that we flashed on the board in the previous lesson.

In the exercise section of this lesson, we will learn how to use the GPIO peripheral to control LEDs and read the status of buttons using both polling and interrupts methods.


  • Examine the devicetree API <zephyr/devicetree.h>
  • Examine board-level devicetree .dts
  • Examine SoC-level devicetree .dtsi
  • Understand the purpose of devicetree binding files (.yaml) and the compatible property
  • Understand the device driver model <zephyr/device.h>
  • Analyze the decoupling between a device driver API and a device driver implementation and the need to have a device pointer
  • Examine the generic GPIO interface APIs <zephyr/drivers/gpio.h>
  • Practice through hands-on exercises configuring GPIO pins and learn how to read/write to/from GPIO pins and how to set up interrupts for input GPIO pins
Register an account
Already have an account? Log in
(All fields are required unless specified optional)

  • 8 or more characters
  • Upper and lower case letters
  • At least one number or special character

Forgot your password?
Enter the email associated with your account, and we will send you a link to reset your password.