Introduction
Authors: Alexandru Niculae, Catalin Visan, Microchip Technology Inc. |
The purpose of this document is to describe step-by-step how to use the microcontroller’s pins as General Purpose Input/Output (GPIO) on Microchip tinyAVR® 0- and 1-series, megaAVR® 0-series and AVR® DA devices. The following use cases are presented:
- Blink an LED:
Blink an LED using a delay, toggling the LED every 500 ms.
- Long and Short Button
Press:
Use a pin as input to distinguish between a long and short button press, defined by a delay threshold. An LED will toggle every 100 ms if a long press is detected, and every 500 ms if a short press is detected.
- Wake-Up On Button
Press:
Exit sleep on button press, turn on an LED, and go back to sleep. On button release - exit sleep, turn off the LED, and go back to sleep.