Code is Compiling but arduino doesn't execute

I was hoping to get a little help understanding why my code isn’t working. Before posting this I tried writing it in different ways and looking up as much as I could on the subject. My goal is to have it go to sleep on a push of a button/switch or after in idle for a few hours(if forgotten on). This is just example code that I’m trying to build off of but keep hitting a wall with what I can get to work. It turns itself off after some time, and I can get it to turn back on. But it won’t go to sleep on the same button press that turns it on.

#include <avr/sleep.h>


int wakePin = 2;                 // pin used for waking up
int sleepStatus = 0;             // variable to store a request for sleep
int count = 0;                   // counter

void wakeUpNow()        // here the interrupt is handled after wakeup
{
  // execute code here after wake-up before returning to the loop() function
  // timers and code using timers (serial.print and more...) will not work here.
  // we don't really need to execute any special functions here, since we
  // just want the thing to wake up
}

void setup()
{
  pinMode(wakePin, INPUT);

  Serial.begin(9600);

  attachInterrupt(0, wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function
                                      // wakeUpNow when pin 2 gets LOW 
}

void sleepNow()         // here we put the arduino to sleep
{
   
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here

    sleep_enable();          // enables the sleep bit in the mcucr register
                             // so sleep is possible. just a safety pin 

    attachInterrupt(0,wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function
                                       // wakeUpNow when pin 2 gets LOW 

    sleep_mode();            // here the device is actually put to sleep!!
                             // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP

    sleep_disable();         // first thing after waking from sleep:
                             // disable sleep...
    detachInterrupt(0);      // disables interrupt 0 on pin 2 so the 
                             // wakeUpNow code will not be executed 
                             // during normal running time.

}

void loop()
{
  // display information about the counter
  Serial.print("Awake for ");
  Serial.print(count);
  Serial.println("sec");
  count++;
  delay(1000);                           // waits for a second

  // compute the serial input
  if (Serial.available()) {
    int val = Serial.read();
    if (val == 'S') {
      Serial.println("Serial: Entering Sleep mode");
      delay(100);     // this delay is needed, the sleep 
                      //function will provoke a Serial error otherwise!!
      count = 0;
      sleepNow();     // sleep function called here
    }
    if (val == 'A') {
      Serial.println("Hola Caracola"); // classic dummy message
    }
  }
if(wakePin == HIGH) {
  delay(10);
 Serial.println("Timer: Entering Sleep mode");
      delay(10);     // this delay is needed, the sleep 
                      //function will provoke a Serial error otherwise!!
      count = 0;
      sleepNow();     // sleep function called here
}

  // check if it should go to sleep because of time
  if (count >= 100) {
      Serial.println("Timer: Entering Sleep mode");
      delay(100);     // this delay is needed, the sleep 
                      //function will provoke a Serial error otherwise!!
      count = 0;
      sleepNow();     // sleep function called here
  }
}
if(wakePin == HIGH)

wakePin has a value of 2. HIGH is defined to have a value of 1. 2 will NEVER equal 1.

Perhaps you meant to compare the state of the pin (ie. digitalRead) to HIGH instead of trying to compare the pin number to HIGH.

Delta_G: Perhaps you meant to compare the state of the pin (ie. digitalRead) to HIGH instead of trying to compare the pin number to HIGH.

Yes, you are correct. But I'm pretty sure I wrote it like that as well and it didn't work. I don't have mine in front of me to try atm.

But it won't go to sleep on the same button press that turns it on

Why would you want it to? If you press a button to turn it on, you don't want it to go back to sleep do you?

    delay(100);     // this delay is needed, the sleep

//function will provoke a Serial error otherwise!!

You could always do:

Serial.flush ();

I think you will want to keep track of the previous state of the button. That way if the button is used to wake the processor it will not instantly be used to put the processor to sleep.