Arduino Giga R1 WiFi Button
This guide covers button implementation with the Arduino Giga R1 WiFi. Push buttons are fundamental components in embedded systems for triggering events and controlling states.
This tutorial demonstrates proper button integration including pull-up/pull-down resistor configuration, contact bounce handling, and state detection. You'll learn to avoid common issues like floating input states and implement reliable button control.

※ NOTE THAT:
Before presenting about the button, We would like to notice that there are two common mistakes that newbies usually meet:
- The floating input problem:
- Symptom: When connecting a button to Arduino input pin, the state of the input pin is random and not matched with the button's pressing state.
- Cause: The button pin is NOT used a pull-down resistor or a pull-up resistor.
- Solution: ⇒ Use a pull-down resistor or a pull-up resistor on the input pin. The detail will be described later in this tutorial.
- Symptom: The code on Arduino reads the state of the button and identifies the pressing event by detecting the state change (HIGH to LOW, or LOW to HIGH). When the button is actually pressed only one time, Arduino code detects multiple presses rather than once.
- Cause: Due to mechanical and physical characteristics, when you do a single press on a button, the state of the input pin is quickly toggled between LOW and HIGH several times rather than once
- Solution: ⇒ Debounce. The detail will be described in Arduino - Button - Debounce tutorial.
The chattering phenomenon causes the malfunction in only some kinds of application that needs to detect exactly number of the pressing. In some kind of application, it is harmless.
Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (30 sensors/displays) | |
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Wiring Diagram
The following diagrams demonstrate proper electrical connections between the Arduino Giga R1 WiFi and various button types. Correct wiring ensures reliable operation and prevents damage to the microcontroller's GPIO pins through overcurrent or incorrect voltage application.
Electrical Note: The diagrams below show the minimum viable connection for development and prototyping. For production or extended-use applications, consider adding a 100nF ceramic capacitor across the button terminals to reduce electromagnetic interference and improve noise immunity in electrically noisy environments.
- Wiring Diagram between Arduino and PCB-mount button
| Component Pin | Arduino Giga R1 WiFi Pin |
|---|---|
| Button Terminal 1 | GND |
| Button Terminal 2 | Digital Pin 7 |

This image is created using Fritzing. Click to enlarge image
- Wiring Diagram between Arduino and panel-mount button
| Component Pin | Arduino Giga R1 WiFi Pin |
|---|---|
| Button Terminal 1 | GND |
| Button Terminal 2 | Digital Pin 7 |

This image is created using Fritzing. Click to enlarge image
Power Supply Requirements: Standard tactile switches require no external power supply as they operate as passive switching elements. The Arduino Giga R1 WiFi's internal pull-up resistor provides the necessary bias current (approximately 82µA at 3.3V) for reliable logic level detection without external components.
Current Consumption: Button interface circuits consume minimal power, with quiescent current limited by the pull-up resistor value. Using the internal 40kΩ pull-up resistor results in standby current of approximately 82µA, making it suitable for low-power applications where multiple buttons are monitored continuously.
Arduino Code
The following implementation demonstrates basic button state monitoring using the Arduino Giga R1 WiFi's digital input capabilities. The code is structured to handle continuous polling with serial output for development and debugging purposes. Key sections include pin initialization, state reading, and output formatting for clear monitoring of button behavior.
Detailed Instructions
For initial Arduino Giga R1 WiFi setup, refer to the Arduino Giga R1 WiFi Getting Started guide before proceeding.
- Connect Hardware: Wire the button to Arduino Giga R1 WiFi pin 7 and GND according to the wiring diagram. Verify connections are secure and correct before applying power.
- Open Arduino IDE: Launch the Arduino IDE and confirm the Arduino Giga R1 WiFi board is selected in the Tools menu. Set the appropriate COM port for your connection.
- Load Code: Copy the button monitoring code below and paste it into a new Arduino IDE sketch. Review the pin assignments and modify if using different GPIO pins.
- Upload Code: Click the Upload button to compile and transfer the code to the Arduino Giga R1 WiFi. Monitor the compilation process for any errors or warnings.
- Open Serial Monitor: Access the Serial Monitor from the Tools menu and set the baud rate to 9600. This displays real-time button state information for monitoring and debugging.
- Test Operation: Press and release the button while observing the Serial Monitor output. Verify that state changes are detected correctly and timing appears responsive.
- Verify Logic Levels: Confirm that unpressed button shows HIGH (1) and pressed button shows LOW (0) when using INPUT_PULLUP configuration. Inconsistent readings indicate wiring errors.
Technical Note: The Arduino Giga R1 WiFi's dual-core architecture allows button monitoring to run independently of other tasks using FreeRTOS task scheduling. For complex applications, consider implementing button handling in a dedicated task to ensure responsive user interface behavior.
- Click Upload button on Arduino IDE to upload code to Arduino

- Open Serial Monitor
- Press and release the button several time
- See the result on Serial Monitor:
1 is HIGH, 0 is LOW.
Code Explanation
Read the line-by-line explanation in comment lines of code!
Modifying Arduino Code
The following modification demonstrates event-driven button handling that detects press and release actions rather than continuous state monitoring. This approach is more suitable for applications requiring specific response to user actions, such as menu navigation, device control, or state toggling functions.
Let's modify the code to detect the press and release events
Detailed Instructions
- Modify Implementation: Replace the continuous state monitoring with edge detection logic that identifies press and release events. This reduces serial output volume and focuses on meaningful user interactions.
- Update Code: Copy the modified button event detection code and replace the previous implementation. The new version tracks state transitions rather than absolute states.
- Upload Modified Code: Compile and upload the updated code to the Arduino Giga R1 WiFi. Monitor for compilation errors that might indicate syntax issues or missing dependencies.
- Test Event Detection: Press and release the button deliberately while monitoring the Serial Monitor. Each press action should generate one press event and one release event message.
- Verify Event Timing: Observe that events are detected immediately upon button action without significant delay. The Arduino Giga R1 WiFi's fast GPIO polling ensures responsive event detection.
- Check for Multiple Events: Note that mechanical button bounce may cause multiple event detections per physical press. This is normal behavior that can be addressed through debouncing techniques.
Technical Note: Event-driven button handling reduces processor overhead by responding only to state changes rather than continuous polling. For applications monitoring multiple buttons, this approach scales better and reduces power consumption in battery-operated systems.
- Click Upload button on Arduino IDE to upload code to Arduino

- Open Serial Monitor
- Press the button and then release
- See the result on Serial Monitor
※ NOTE THAT:
- Even you pressed and released the button only once, the output in Serial Monitor may show several pressed and release events. This is the normal behavior of the button. This behavior is called the "chattering phenomenon". You can learn more in Arduino - Button Debounce tutorial.
- To make it much easier for beginners, especially when using multiple buttons, we created a library, called ezButton. You can learn about ezButton library here.
- Use pinMode(BUTTON_PIN, INPUT) for the button module. It outputs LOW when not pressed and HIGH when pressed.
Challenge Yourself
Implement these advanced button control systems to deepen your understanding of embedded interface design and expand the practical capabilities of your Arduino Giga R1 WiFi projects:
Challenge: Implement LED control with immediate button response — Create a system where an LED turns ON when the button is pressed and OFF when released. Add PWM brightness control based on press duration for advanced functionality.
Challenge: Design a toggle system with state persistence — Build a button interface that toggles an LED between ON and OFF states with each press, maintaining the state across power cycles using the Arduino Giga R1 WiFi's built-in storage capabilities.
Challenge: Create a multi-function button interface — Implement short press, long press, and double-click detection using a single button. Each action should trigger different responses, demonstrating advanced event processing with the Giga R1 WiFi's timing capabilities.
Challenge: Build a button matrix controller — Connect 4 buttons in a 2x2 matrix configuration and implement scanning algorithms to detect individual button presses. Utilize the Arduino Giga R1 WiFi's abundant GPIO pins for efficient matrix scanning.
Challenge: Implement WiFi-connected button control — Use the Arduino Giga R1 WiFi's built-in WiFi capabilities to send button press events to a remote server or mobile app, creating an IoT button interface for smart home applications.
Application Ideas
Button interfaces serve as fundamental components in numerous professional and industrial applications where reliable user interaction is essential:
Industrial Control Panel: Implement emergency stop buttons, process control switches, and mode selection interfaces for manufacturing equipment. The Arduino Giga R1 WiFi's robust GPIO design enables reliable operation in electrically noisy industrial environments with proper shielding and debouncing.
Smart Home Controller: Create centralized control systems for lighting, HVAC, and security functions using multiple buttons with the Arduino Giga R1 WiFi's WiFi connectivity. The board's dual-core architecture enables simultaneous local button processing and wireless communication for responsive smart home integration.
Data Logger Interface: Build portable measurement systems where buttons control logging functions, mode selection, and data upload processes. The Arduino Giga R1 WiFi's expanded memory and processing power support complex logging applications with real-time button-controlled data management.
Medical Device Interface: Develop patient monitoring or therapeutic device controls requiring reliable button response and safety interlocks. The board's deterministic timing capabilities ensure critical button functions operate within required response time specifications.
Automotive Test Equipment: Implement diagnostic tool interfaces for automotive applications where buttons control test sequences and parameter selection. The Arduino Giga R1 WiFi's processing power enables real-time test control with immediate button response for professional automotive diagnostics.
Security System Panel: Create access control and alarm system interfaces using button inputs for code entry, system arming, and emergency functions. Integration with the board's communication capabilities enables remote monitoring and control of security button interfaces.
Challenge Yourself
- Basic Implementation: Turn on LED when button is pressed and turn off LED when button is NOT pressed. Implement immediate response without noticeable delay for professional user experience.
- Toggle Control System: Toggle LED between ON and OFF each time the button is pressed. Add state indication through different LED patterns to confirm toggle operation success.
- Multi-Button Interface: Implement a 4-button keypad system where each button controls different functions. Use the Arduino Giga R1 WiFi's interrupt capabilities for immediate response to any button press.
- Wireless Button Control: Utilize the Arduino Giga R1 WiFi's built-in connectivity to transmit button events to a remote device or web server. Implement reliable transmission with error handling and acknowledgment protocols.
- Advanced Debouncing System: Create a software debouncing algorithm that handles multiple buttons simultaneously while maintaining precise timing. Use the dual-core architecture to dedicate processing resources for reliable button handling.
Additional Knowledge
Understanding when to implement pull-up or pull-down resistors is crucial for reliable embedded system design and prevents common interface problems that can compromise system reliability:
- Requirement for Pull Resistors: If the sensor has either closed (connected to VCC or GND) or open (NOT connected to anything) states, you need a pull-up or pull-down resistor to make these states become two defined logic levels: LOW and HIGH. This applies to mechanical switches, reed switches, push-buttons, magnetic contact switches (door sensor), and any device that provides open-circuit or short-circuit states rather than defined voltage levels.
- No Pull Resistor Required: If the sensor has two defined voltage levels (LOW and HIGH), you do NOT need a pull-up or pull-down resistor because the device actively drives the output to specific voltage levels. For example, motion sensor, touch sensor, and digital sensor modules with integrated signal conditioning circuits provide clean logic levels without external biasing components.
Technical Implementation Guidelines: The Arduino Giga R1 WiFi's internal pull-up resistors (approximately 40kΩ) are suitable for most button applications and eliminate external components. For applications requiring faster switching speeds or lower power consumption, external pull-up resistors in the 1kΩ to 10kΩ range provide improved performance at the cost of increased current consumption.




