Going faster everytime...

unsigned long Lamp = 0;
unsigned long powerdown = 0;

hm

unsigned long Lamp = 0;
unsigned long powerdown = 0;

Add to that list

 unsigned long tone = 0;

Every variable used in the conditional test with the millis() and then assigned the value of millis() needs to be unsigned long.

Okay so i've changed those to unsigned long! Still it would seem that it keeps time and adds it onto everything so... if i start the program and then test to turn it off with those two buttons at the same time and wait 5 sec and then start the program then it only takes 25 sec to actually turn of a led.

But can i say...
LampCM = millis();
and the same for the tone and powerdown? So that we don't everything on CM.

should not CM = powerdown; be powerdown = CM; ?

Juraj:
should not CM = powerdown; be powerdown = CM; ?

Yes but somehow it still works..

Lexianlex:
Yes but somehow it still works..

sure it works. it is only for CM - powerdown >= 1000

Juraj:
sure it works. it is only for CM - powerdown >= 1000

Yeah..

I think that "lamp" needs to be reset.

Try

if (reading == LOW)     
  {
    Interval = 1;       //THE FIRST BUTTON WILL ACTIVATE MY CODE!
    lamp = CM
  }

should not CM = powerdown; be powerdown = CM; ?

Yes, this should be fixed.

cattledog:
I think that "lamp" needs to be reset.

Try

if (reading == LOW)     

{
    Interval = 1;      //THE FIRST BUTTON WILL ACTIVATE MY CODE!
    lamp = CM
  }




Yes, this should be fixed.

Well that kinda fixed that! But now when the program goes without doing anything else but waiting those 2 min out, the program only does the pip noise when i push the button again..

Also i cannot shut off everything with my two buttons when i bypass around 10 sec. So i can shut it down really early but not after.

Post your code as it is now

int sound = 3;
int led4 = 4;
int led5 = 5;
int led6 = 6;
int led7 = 7;
int buttonPin = 2;
int buttonPin2 = 9;
long CM = 0;
long Interval = 0;
long cat = 0;
long pip = 1;
unsigned long Lamp = 0;
unsigned long Tone = 100;
int action = 0;
int adding = 0;
unsigned long powerdown = 0;

void setup()
{
  pinMode(2, INPUT_PULLUP); //TWO BUTTONS!
  pinMode(9, INPUT_PULLUP);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  unsigned long CM = millis();          //MY MILLIS
  int reading = digitalRead(buttonPin);   //READING MY BUTTONS!
  int reading2 = digitalRead(buttonPin2);



  if (reading == LOW)
  {
    Interval = 1;       //THE FIRST BUTTON WILL ACTIVATE MY CODE!
    Lamp = CM;
  }




  if (reading2 == LOW)
  {
    adding++;         //THE SECOND BUTTON SHALL ONLY ACT WHEN BOTH THE SECOND AND FIRST
  }                   //BUTTON ARE PRESSED TOGETHER FOR ATLEAST 1 SEC.
  else
  {
    adding = 0;
  }





  if (Interval == 1)      //IF WE PRESS THE FIRST BUTTON THEN WE CAN ONLY ACTIVATE THE CODE ONCE!
  {
    if (CM - Lamp > 30000)    //EVERY 30 SEC WE TURN OF 1 OUT OF OUR 4 LIGHTS!
    {
      Lamp = CM;
      pip = 1;
      action++;
      if (action >= 5)
      {
        action = 0;
      }
    }
    switch (action)
    {
      case 0:
        digitalWrite(4, HIGH);
        digitalWrite(5, HIGH);
        digitalWrite(6, HIGH);
        digitalWrite(7, HIGH);
        break;
      case 1:
        digitalWrite(4, LOW);
        break;
      case 2:
        digitalWrite(5, LOW);
        break;
      case 3:
        digitalWrite(6, LOW);
        break;
      case 4:
        digitalWrite(7, LOW);
        Interval = 0;
        cat = 1;
        break;
      case 5:
        delay(10);
        break;
      default:
        break;
    }
  }


  if (cat == 1)     //ONCE THE LAMP CODE IS DONE THEN THE SOUND CODE STARTS
  {
    if (CM - Tone > 150)
    {
      Tone = CM;
      tone(sound, 400, 50);
      Serial.println("Ljud");

      pip++;
    }
  }
  if (pip == 4)   //ONCE WE HAVE HEARD A SOUND MAKE A "PIP" 3 TIMES THEN IT RESTARTS. AND "PIP = 1" FROM THE BEGINING!
  {
    Interval = 0;
    pip = 1;
    cat = 0;
  }





  if (adding >= 1)    //WHEN THE SECOND BUTTON IS PUSHED THEN SOMETHING HAPPENS
  {
    powerdown = CM;
  }

  if ((reading == LOW) && (reading2 == LOW))
  {

  }
  else
  {
    powerdown = CM;
  }
  if (CM - powerdown > 1000)   //WHEN BOTH BUTTONS ARE PUSHED THEN WE SHUT EVERYTHING OFF!
  {
    Interval = 0;
    pip = 1;
    cat = 0;

    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
  }

}
// The thing is that we have 1 value for every different time, which is CM. So maybe that makes things more difficult.
// However when runing this code, the time almost goes faster and fast until a point when i push the button and we instantly
// skip the lamps and the sounds comes right after that...

UKHeliBob:
Post your code as it is now

if (adding >= 1)    //WHEN THE SECOND BUTTON IS PUSHED THEN SOMETHING HAPPENS
  {
    powerdown = CM;
  }

  if ((reading == LOW) && (reading2 == LOW))
  {

  }
  else
  
    powerdown = CM;
  }
  if (CM - powerdown > 1000)   //WHEN BOTH BUTTONS ARE PUSHED THEN WE SHUT EVERYTHING OFF!
  {
    Interval = 0;
    pip = 1;
    cat = 0;

    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
  }

This code does not look correct to me, and I think you are inadvertantly entering powerdown.

I would set a boolean flag with the buttpon/buttons to enable powerdown with the button press rather than setting it = CM. Then if powerdown == true enable some timing sequence.

I was staring at that code, reformatting, renaming variables to more meaningful names and so. It is state machine with too many state variables. It needs a rewrite.

int sound = 3;
int led4 = 4;
int led5 = 5;
int led6 = 6;
int led7 = 7;
int buttonPin = 2;
int buttonPin2 = 9;

long intervalState = 0;
int catState = 0;
int pipState = 1;
unsigned long lastLamp = 0;
unsigned long lastTone = 100;
int actionState = 0;
int counter = 0;
unsigned long lastPowerdown = 0;

void setup() {
  pinMode(2, INPUT_PULLUP); //TWO BUTTONS!
  pinMode(9, INPUT_PULLUP);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  unsigned long currentMillis = millis();          //MY MILLIS
  int reading = digitalRead(buttonPin);   //READING MY BUTTONS!
  int reading2 = digitalRead(buttonPin2);

  if (reading == LOW) {
    intervalState = 1;       //THE FIRST BUTTON WILL ACTIVATE MY CODE!
  }

  if (reading2 == LOW) {
    counter++;  //THE SECOND BUTTON SHALL ONLY ACT WHEN BOTH THE SECOND AND FIRST
  }                   //BUTTON ARE PRESSED TOGETHER FOR ATLEAST 1 SEC.
  else {
    counter = 0;
  }

  if (intervalState == 1) //IF WE PRESS THE FIRST BUTTON THEN WE CAN ONLY ACTIVATE THE CODE ONCE!
      {
    if (currentMillis - lastLamp > 30000)    //EVERY 30 SEC WE TURN OFF 1 OUT OF OUR 4 LIGHTS!
        {
      lastLamp = currentMillis;
      pipState = 1;
      actionState++;
      if (actionState >= 5) {
        actionState = 0;
      }
    }
    switch (actionState) {
      case 0:
        digitalWrite(4, HIGH);
        digitalWrite(5, HIGH);
        digitalWrite(6, HIGH);
        digitalWrite(7, HIGH);
        break;
      case 1:
        digitalWrite(4, LOW);
        break;
      case 2:
        digitalWrite(5, LOW);
        break;
      case 3:
        digitalWrite(6, LOW);
        break;
      case 4:
        digitalWrite(7, LOW);
        intervalState = 0;
        catState = 1;
        break;
      case 5:
        delay(10);
        break;
      default:
        break;
    }
  }

  if (catState == 1)     //ONCE THE LAMP CODE IS DONE THEN THE SOUND CODE STARTS
      {
    if (currentMillis - lastTone > 150) {
      lastTone = currentMillis;
      tone(sound, 400, 50);
      Serial.println("Ljud");

      pipState++;
    }
  }
  if (pipState == 4) //ONCE WE HAVE HEARD A SOUND MAKE A "PIP" 3 TIMES THEN IT RESTARTS. AND "PIP = 1" FROM THE BEGINING!
      {
    intervalState = 0;
    pipState = 1;
    catState = 0;
  }

  if (counter >= 1)    //WHEN THE SECOND BUTTON IS PUSHED THEN SOMETHING HAPPENS
      {
    currentMillis = lastPowerdown;
  }

  if ((reading == LOW) && (reading2 == LOW)) {

  } else {
    currentMillis = lastPowerdown;
  }
  if (currentMillis - lastPowerdown >= 1000) { //WHEN BOTH BUTTONS ARE PUSHED THEN WE SHUT EVERYTHING OFF!
    intervalState = 0;
    pipState = 1;
    catState = 0;

    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
  }

}

Mate i like how you set everything up, but i still cannot figure out how to fix my problems; That it doesnt actually keep 30 sec apart and starts way to early. But the good thing is that this code actually can stop everything whenever both buttons are pushed!

So i guess that someone there must be a "restart" of millis when we push down both buttons?
If we press down the first button and wait then it actually goes for the right amount of time, but it doesn't if we start the program and then shut it off with both buttons and wait for some time and then try to start eveyrthing with button nr 1.

Juraj:
I was staring at that code, reformatting, renaming variables to more meaningful names and so. It is state machine with too many state variables. It needs a rewrite.

int sound = 3;

int led4 = 4;
int led5 = 5;
int led6 = 6;
int led7 = 7;
int buttonPin = 2;
int buttonPin2 = 9;

long intervalState = 0;
int catState = 0;
int pipState = 1;
unsigned long lastLamp = 0;
unsigned long lastTone = 100;
int actionState = 0;
int counter = 0;
unsigned long lastPowerdown = 0;

void setup() {
 pinMode(2, INPUT_PULLUP); //TWO BUTTONS!
 pinMode(9, INPUT_PULLUP);
 pinMode(3, OUTPUT);
 pinMode(4, OUTPUT);
 pinMode(5, OUTPUT);
 pinMode(6, OUTPUT);
 pinMode(7, OUTPUT);
 Serial.begin(9600);
}

void loop() {
 unsigned long currentMillis = millis();          //MY MILLIS
 int reading = digitalRead(buttonPin);   //READING MY BUTTONS!
 int reading2 = digitalRead(buttonPin2);

if (reading == LOW) {
   intervalState = 1;       //THE FIRST BUTTON WILL ACTIVATE MY CODE!
 }

if (reading2 == LOW) {
   counter++;  //THE SECOND BUTTON SHALL ONLY ACT WHEN BOTH THE SECOND AND FIRST
 }                   //BUTTON ARE PRESSED TOGETHER FOR ATLEAST 1 SEC.
 else {
   counter = 0;
 }

if (intervalState == 1) //IF WE PRESS THE FIRST BUTTON THEN WE CAN ONLY ACTIVATE THE CODE ONCE!
     {
   if (currentMillis - lastLamp > 30000)    //EVERY 30 SEC WE TURN OFF 1 OUT OF OUR 4 LIGHTS!
       {
     lastLamp = currentMillis;
     pipState = 1;
     actionState++;
     if (actionState >= 5) {
       actionState = 0;
     }
   }
   switch (actionState) {
     case 0:
       digitalWrite(4, HIGH);
       digitalWrite(5, HIGH);
       digitalWrite(6, HIGH);
       digitalWrite(7, HIGH);
       break;
     case 1:
       digitalWrite(4, LOW);
       break;
     case 2:
       digitalWrite(5, LOW);
       break;
     case 3:
       digitalWrite(6, LOW);
       break;
     case 4:
       digitalWrite(7, LOW);
       intervalState = 0;
       catState = 1;
       break;
     case 5:
       delay(10);
       break;
     default:
       break;
   }
 }

if (catState == 1)     //ONCE THE LAMP CODE IS DONE THEN THE SOUND CODE STARTS
     {
   if (currentMillis - lastTone > 150) {
     lastTone = currentMillis;
     tone(sound, 400, 50);
     Serial.println("Ljud");

pipState++;
   }
 }
 if (pipState == 4) //ONCE WE HAVE HEARD A SOUND MAKE A "PIP" 3 TIMES THEN IT RESTARTS. AND "PIP = 1" FROM THE BEGINING!
     {
   intervalState = 0;
   pipState = 1;
   catState = 0;
 }

if (counter >= 1)    //WHEN THE SECOND BUTTON IS PUSHED THEN SOMETHING HAPPENS
     {
   currentMillis = lastPowerdown;
 }

if ((reading == LOW) && (reading2 == LOW)) {

} else {
   currentMillis = lastPowerdown;
 }
 if (currentMillis - lastPowerdown >= 1000) { //WHEN BOTH BUTTONS ARE PUSHED THEN WE SHUT EVERYTHING OFF!
   intervalState = 0;
   pipState = 1;
   catState = 0;

digitalWrite(4, LOW);
   digitalWrite(5, LOW);
   digitalWrite(6, LOW);
   digitalWrite(7, LOW);
 }

}

you still not debounce the buttons so hard to say what happens. add debug prints and you will see why you need debounce the buttons

The variable names in Juraj's code are an inprovement, so lets work from there.

That it doesnt actually keep 30 sec apart and starts way to early.

The code does not pick up the reset of lastLamp like you did when it was called Lamp.

if (reading == LOW) {
    intervalState = 1; 
    lastLamp = currentMillis;      //THE FIRST BUTTON WILL ACTIVATE MY CODE!
  }

I believe that this should be switched around in the two cases where it appears

//currentMillis = lastPowerdown;
lastPowerdown = currentMillis;

Please describe how the program is performing with these changes.

I still think the power down section needs work. Can you try explaining again what it is not doing correctly.

But the good thing is that this code actually can stop everything whenever both buttons are pushed!

So i guess that someone there must be a "restart" of millis when we push down both buttons?
If we press down the first button and wait then it actually goes for the right amount of time, but it doesn't if we start the program and then shut it off with both buttons and wait for some time and then try to start eveyrthing with button nr 1.

Okay boys and girls... here is the deal.

The program almost works now. I can wait it out and it works and i can restart it!
But now i need to use four buttons instead.
And for each button there is an 2 min decrease.

So the first button is for 8 min
the second for 6 min, the third for 4 min and the forth for 2 min.
And the forth and the first button together should be able to shutdown everything!

BUT; I feel like it wouldn't be too hard to just take my code in the middle, which does all the lamp work, and to just copy that and do 3 more of those. But i need to be able to start one part of the program with one button and i need to make sure of that i cannot start anything else but the other three buttons nor should i be able to stop anything other than to hold down the first and forth button at the same time.

But... the code gets to be too long! I really don't want it to be so long and i feel like there is some other way to make it shorter and more effective!

And i know that there is other parts of the code that i could fix but for now it would be nice to get the main parts done and then focus on the rest so that everything works like it should be working!

I will try to actually read what you guys tell me to do! I am new to all of this but i am trying to hold on and learn!

int sound = 3;
int led4 = 4;
int led5 = 5;
int led6 = 6;
int led7 = 7;
int buttonPin = 2;
int buttonPin2 = 9;
int buttonPin3 = 10; //This isnt in the code yet. 
int buttonPin4 = 11; //This is also not in the code yet! 

long intervalState = 0;
int catState = 0;
int pipState = 1;
unsigned long lastLamp = 0;
unsigned long lastTone = 100;
int actionState = 0;
int counter = 0;
unsigned long lastPowerdown = 0;

void setup() {
  pinMode(2, INPUT_PULLUP); //TWO BUTTONS!
  pinMode(9, INPUT_PULLUP);
  pinMode(10, INPUT_PULLUP); //TWO BUTTONS!
  pinMode(11, INPUT_PULLUP);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  unsigned long currentMillis = millis();          //MY MILLIS
  int reading = digitalRead(buttonPin);   //READING MY BUTTONS!
  int reading2 = digitalRead(buttonPin2);

  if (reading == LOW) {
    intervalState = 1;
    lastLamp = currentMillis;
    //THE FIRST BUTTON WILL ACTIVATE MY CODE!
  }

  if (reading2 == LOW) {
    counter++;  //THE SECOND BUTTON SHALL ONLY ACT WHEN BOTH THE SECOND AND FIRST
  }                   //BUTTON ARE PRESSED TOGETHER FOR ATLEAST 1 SEC.
  else {
    counter = 0;
  }






  //This whole if statement is the problem! 
  if (intervalState == 1) //IF WE PRESS THE FIRST BUTTON THEN WE CAN ONLY ACTIVATE THE CODE ONCE!
  {
    if (currentMillis - lastLamp > 30000)    //EVERY 30 SEC WE TURN OFF 1 OUT OF OUR 4 LIGHTS!
    {
      lastLamp = currentMillis;
      pipState = 1;
      actionState++;
      if (actionState >= 5) {
        actionState = 0;
      }
    }
    switch (actionState) {
      case 0:
        digitalWrite(4, HIGH);
        digitalWrite(5, HIGH);
        digitalWrite(6, HIGH);
        digitalWrite(7, HIGH);
        break;
      case 1:
        digitalWrite(4, LOW);
        break;
      case 2:
        digitalWrite(5, LOW);
        break;
      case 3:
        digitalWrite(6, LOW);
        break;
      case 4:
        digitalWrite(7, LOW);
        intervalState = 0;
        catState = 1;
        break;
      case 5:
        delay(10);
        break;
      default:
        break;
    }
  }
  //And it ends here!



//SEC-2 


  //These are nothing that we should do any changing in!
  if (catState == 1)     //ONCE THE LAMP CODE IS DONE THEN THE SOUND CODE STARTS
  {
    if (currentMillis - lastTone > 150) {
      lastTone = currentMillis;
      tone(sound, 400, 50);
      Serial.println("Ljud");

      pipState++;
    }
  }
  if (pipState == 4) //ONCE WE HAVE HEARD A SOUND MAKE A "PIP" 3 TIMES THEN IT RESTARTS. AND "PIP = 1" FROM THE BEGINING!
  {
    intervalState = 0;
    pipState = 1;
    catState = 0;
    actionState = 0;
    lastLamp = currentMillis;
  }

  if (counter >= 1)    //WHEN THE SECOND BUTTON IS PUSHED THEN SOMETHING HAPPENS
  {
    currentMillis = lastPowerdown;
  }

  if ((reading == LOW) && (reading2 == LOW)) {

  } else {
    currentMillis = lastPowerdown;
  }
  if (currentMillis - lastPowerdown >= 1000) { //WHEN BOTH BUTTONS ARE PUSHED THEN WE SHUT EVERYTHING OFF!
    intervalState = 0;
    pipState = 1;
    catState = 0;
    actionState = 0;
    lastLamp = currentMillis;

    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
  }

}