Question: Task 2 : Exploring Sleep Modes with Wake - Up Button 1 . Objective: Put the Arduino into Power - down sleep mode to conserve

Task 2: Exploring Sleep Modes with Wake-Up Button
1. Objective: Put the Arduino into Power-down sleep mode to conserve power and wake it up using a button interrupt.
2. Instructions:
- Configure the Arduino to enter Power-down mode when idle.
- Attach a button to pin \(\mathbf{3}\) to wake the Arduino when pressed.
- In sleep mode, all unnecessary functions are disabled, and the Arduino only wakes up when the button interrupt is triggered.
3. Code Template:
```
#include
#include
const int buttonPin =3;
void setup(){
pinMode(buttonPin, INPUT_PULLUP); // Set button as input with pull-up
attachInterrupt(digitalPinToInterrupt(buttonPin), wakeUp, FALLING); // Interrupt
on button press
Serial.begin(9600); // Optional: for monitoring in Serial
Monitor
}
void loop(){
Serial.println("Going to sleep..."):
delav(1000);
// Configure sleep mode
set sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep enable();
sleepmode(); // Put the Arduino to sleep
// The Arduino resumes here after wake-up
Serial.println("Woke up!"\);
delay(1000): // Wait a moment before going back to
sleep
}
void wakeUp(){
// This function just interrupts sleep mode; no code needed
}
```
Questions and Analysis
1. Task 1: Describe how CTC mode allows for precise timing control without using delav(). How does changing the prescaler or compare match value affect the blink interval?
2. Task 2: How does Power-down mode save power compared to other sleep modes? Describe the function of the button interrupt in waking up the Arduino from sleep mode.
Task 2 : Exploring Sleep Modes with Wake - Up

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Electrical Engineering Questions!