0
0
Arduinoprogramming~30 mins

Wake-up from sleep with interrupt in Arduino - Mini Project: Build & Apply

Choose your learning style9 modes available
Wake-up from Sleep with Interrupt
📖 Scenario: You are building a simple Arduino project that saves power by going to sleep and wakes up only when a button is pressed. This is useful for battery-powered devices that need to stay off most of the time and react only to user input.
🎯 Goal: Create an Arduino program that puts the board to sleep and wakes it up using an external interrupt triggered by a button press.
📋 What You'll Learn
Use the LowPower library to manage sleep mode
Set up a button connected to pin 2 to trigger an interrupt
Use an interrupt service routine (ISR) to wake the Arduino
Print a message to the Serial Monitor when the Arduino wakes up
💡 Why This Matters
🌍 Real World
Battery-powered devices like remote sensors or wearable gadgets often need to save power by sleeping and waking only when needed.
💼 Career
Understanding interrupts and power management is essential for embedded systems engineers and IoT developers to build efficient, low-power devices.
Progress0 / 4 steps
1
Setup button input and Serial communication
Write code to set up the button on pin 2 as an input with an internal pull-up resistor. Also, start the Serial communication at 9600 baud in the setup() function.
Arduino
Need a hint?

Use pinMode to set the button pin as input with pull-up. Use Serial.begin(9600) to start serial communication.

2
Configure interrupt to wake from sleep
Add code to attach an interrupt on pin 2 that triggers on a falling edge. Create an empty interrupt service routine called wakeUp that will be called when the interrupt occurs.
Arduino
Need a hint?

Use attachInterrupt(digitalPinToInterrupt(2), wakeUp, FALLING) to set the interrupt. The ISR wakeUp should be empty or very short.

3
Put Arduino to sleep and wake on interrupt
Include the LowPower.h library at the top. In the loop() function, put the Arduino to sleep using LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF). The Arduino will wake up when the interrupt triggers.
Arduino
Need a hint?

Include the LowPower library and call LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF) inside loop() to sleep indefinitely until interrupt.

4
Print message after waking up
Add a Serial.println("Woke up!") statement right after the sleep call in the loop() function to show when the Arduino wakes up.
Arduino
Need a hint?

Use Serial.println("Woke up!") after the sleep call to show the wake-up message.