Azure Sphere – GPIO
This sample application demonstrates how to use a general-purpose input/output (GPIO) with Azure Sphere in a high-level application.
A GPIO is used to read the state of button A and to change the blink rate of LED 1 in response to a button press. The sample allows three possible blink rates for the LED.
The sample uses the following Azure Sphere libraries.
|eventloop||Invokes handlers for timer events.|
|gpio||Accesses button A and LED 1 on the device.|
|log||Displays messages in the Device Output window during debugging.|
||Application manifest file, which describes the resources.|
||CMake configuration file, which Contains the project information and is required for all builds.|
||JSON file for configuring Visual Studio to use CMake with the correct command-line options.|
||JSON file that tells Visual Studio how to deploy and debug the application.|
||The license for this sample application.|
||Main C source code file.|
||This README file.|
||Folder containing the JSON files that configure Visual Studio Code for building, debugging, and deploying the application.|
||Folder containing the hardware definition files for various Azure Sphere boards.|
The sample requires the following hardware:
- Seeed MT3620 Development Kit or other hardware that implements the MT3620 Reference Development Board (RDB) design.
Note: By default, this sample targets MT3620 reference development board (RDB) hardware, such as the MT3620 development kit from Seeed Studio. To build the sample for different Azure Sphere hardware, change the Target Hardware Definition Directory in the CMakeLists.txt file. For detailed instructions, see the README file in the HardwareDefinitions folder.
Ensure that your Azure Sphere device is connected to your computer, and your computer is connected to the internet.
Even if you've performed this setup previously, ensure that you have Azure Sphere SDK version 21.04 or above. At the command prompt, run azsphere show-version to check. Upgrade the Azure Sphere SDK for Windows or Linux as needed.
Enable application development, if you have not already done so, by entering the following line at the command prompt:
azsphere device enable-development
Build and run the sample
To build and run this sample, follow the instructions in Build a sample application.
Test the sample
The output messages are displayed in the Device Output window during debugging.
LED1 on the MT3620 begins blinking red. Press button A on the MT3620 repeatedly to cycle through the three possible LED blink rates.