millis() and if loop not working properly

[int32_t frequency = 20;
#include <PWM.h> 

#define state_button 2  // Pushbutton for driving the device into the differents states
#define enA 9         // PWM pin


int reading_state;        // current reading from the input pin of the state button
int previous_state = LOW; // previous reading from the input pin of the state button
int state = 0;

// the follow variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long time_state = 0;         // the last time the output pin was toggled
long time_ampl = 0;
long time_freq = 0;
long debounce = 300; // the debounce time, increase if the output flickers

long time_state0 = 0;
long time_state1 = 0;
long time_state2 = 0;  



void setup() {
  Serial.begin(9600);
  pinMode(state_button, INPUT);
  pinMode(enA, OUTPUT);
  InitTimersSafe(); 
  bool success = SetPinFrequencySafe(enA, frequency);
}

void loop() {


  reading_state = digitalRead(state_button);
  if(reading_state==HIGH && previous_state == LOW && millis()-time_state>debounce)
    {
      state++;
      if(state > 2)
        {
          state = 0;
        }
        time_state = millis();
    }
  previous_state = reading_state; 
  //Serial.println(state);  
  
  
  if(state == 0 && millis() > 0)  // State1: Soft Mode
    {      
        
        time_state0 = millis();   // initial time
        if (time_state0 % 10000 == 1000){
          pwmWrite(enA,10); 
          Serial.println("01");  
          }
        if (time_state0 % 10000 == 2000){
          pwmWrite(enA,50); 
          Serial.println("02");
          }
        if (time_state0 % 10000 == 4000){
          pwmWrite(enA,100); 
          Serial.println("03");
          //time_state0 = 0; 
          }
        if (time_state0 % 10000 == 7000){
          pwmWrite(enA,150); 
          Serial.println("04");
          }      
         
    }
    millis()== 0;

  if(state == 1 && millis()  > 0)  //State2: Intermediate mode
    {
        
        time_state1 = millis();   // initial time
        if (time_state1 % 12000 == 1000){
          pwmWrite(enA,10); 
          Serial.println("11");  
          }
        if (time_state1 % 12000 == 2000){
          pwmWrite(enA,50); 
          Serial.println("12");
          }
        if (time_state1 % 12000 == 4000){
          pwmWrite(enA,100); 
          Serial.println("13");
          //time_state0 = 0; 
          }
        if (time_state1 % 12000 == 7000){
          pwmWrite(enA,150); 
          Serial.println("14");
          }
        if (time_state1 % 12000 == 9000){
          pwmWrite(enA,200); 
          Serial.println("15");
          }   
             
    }
    millis()== 0;

  if(state == 2 && millis() > 0)  // State3: Intense mode
    {   
        time_state2 = millis();   // initial time
        if (time_state0 % 12000 == 1000){
          pwmWrite(enA,10); 
          Serial.println("21");  
          }
        if (time_state2 % 12000 == 2000){
          pwmWrite(enA,50); 
          Serial.println("22");
          }
        if (time_state2 % 12000 == 4000){
          pwmWrite(enA,100); 
          Serial.println("23");
          //time_state0 = 0; 
          }
        if (time_state2 % 12000 == 7000){
          pwmWrite(enA,150); 
          Serial.println("24");
          }
        if (time_state2 % 12000 == 9000){
          pwmWrite(enA,200); 
          Serial.println("25");
          } 
              
    }
    millis()== 0;
}
]

Hi guys I have written a simple programm whcih have 3 states which can be changed by a button press.
three states have different pwm values which will loop with differernt time interval.
so for eg If the code is in 1 state the PWM values changes after time interval. I am using millis() for time record.

The problem is when I am changing the state the loop of 2 state is not starting from 0 it takes the previous time at start at specific position.

The output is like:

01
02
03
04
01
02 --- button pressed
12
13
14---- button pressed
24
25
21
22

What I want is:

01
02
03
04
11
12 -- button pressed
21
22
23 -- button pressed
01
02
03 --- button pressed
11
12
13

the loop should start from 1st if statment but is not working.

Can some one help Please.

Thanks alot

 millis()== 0;

Strange?

I don't know that any of these are your problem but they are good things to fix:

millis() is likely to always be greater than zero.
millis() may skip some values so comparison using == may not work.
You can not set millis() to zero or to any other value.
Variables being used in conjunction with time should be declared as unsigned long and not just long.

A good tutorial for millis() is here:
https://forum.arduino.cc/index.php?topic=503368.0
but there may be others.

I took a quick look at the code and see a couple obvious things.

First "millis() == 0;" does nothing.
It appears that you want it reset the millis() count to zero but it does not do that. Millis() counts continuously until it wraps.

I suspect what you want is to save the current count in a variable and then subtract that later from the current millis() count to determine the time that has passed.

Also, you are correct that a long allows the millis() count to go higher, and unsigned long goes much higher.

Have a look at how millis() is used to manage timing without blocking in Several Things at a Time. It may help with understanding the technique.

And see Using millis() for timing. A beginners guide if you need more explanation.

...R