So what I basically want to do is turn Arduino off, have the IR remote turn it back on, and then use the IR remote normally to do whatever I need it to do.
The issue is that when I turn the Arduino back on, I can't use the remote anymore. Like when I click on UP, nothing is printed.
//includes servo, sleep, and ir libraries
#include <IRremote.h>
#include <Servo.h>
#include <avr/sleep.h>
//attaches pin and decodes ir reciever
int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;
//attaches codes to up and down and defines wake pin
#define UP 0x00FF9867
#define DOWN 0x00FF38C7
#define awake 2
//values of power
int power = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
//enable ir
irrecv.enableIRIn();
//sleep code setup
pinMode(LED_BUILTIN, OUTPUT);
pinMode(awake, INPUT_PULLUP);
digitalWrite(LED_BUILTIN, HIGH);
//tells arduino to turn off if power = 0
if(power == 0){
gotosleep();
} else if(power == 1){
if (irrecv.decode(&results)){
if (results.value == UP && power == 1){
Serial.println("on");
}
}
}
Serial.println(power);
}
void loop() {
// put your main code here, to run repeatedly:
}
void gotosleep(){
sleep_enable();
attachInterrupt(0, wakeup, LOW);
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
Serial.println("Went to sleep");
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
sleep_cpu();
Serial.println("jsut woke up");
digitalWrite(LED_BUILTIN, HIGH);
}
void wakeup(){
Serial.println("interupt");
sleep_disable();
detachInterrupt(0);
power++;
}