Stop button?

Hi Guys, I have created a little remote control, consisting of a toggle switch, 3 potentiometers and 1 push button.

My idea for the push button was some sort of a stop switch, however, it's only at 1023 while its pressed. So when you release the button, the code rewrites the values the pots are currently set at.

Is there any way to have the push button set everything off, but when you change a potentiometer value or something, it comes back on?

ie, I set "fog" to 40% and "rot" to 60%, then I hit the stop button. This turns everything off. The stop button can be released, and everything remains off. Then I move the potentiometer for fog, and it starts up the fog again. Then when I change the value of the rot pot, it starts rot again etc

Is this possible? Here is my current code:

float h;
int h_int;
int val = 0;
int R = 10;
int G = 6;
int B = 9;
int fog = 0;
int fog1 = 0;
int rot = 0;
int rot1 = 0;
int stp = 0;
int stp1 = 0;
int lig = 0;
int lig1 = 0;
int upd = 0;
int redvar = 0;
int greenvar = 0;
int bluevar = 0;

void setup(){
  pinMode(12, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  Serial.begin(9600);
}

void h2rgb(float H, int& R, int& G, int& B) {

  int var_i;
  float S=1, V=1, var_1, var_2, var_3, var_h, var_r, var_g, var_b;

  if ( S == 0 )                       //HSV values = 0 ÷ 1
  {
    R = V * 255;
    G = V * 255;
    B = V * 255;
  }
  else
  {
    var_h = H * 6;
    if ( var_h == 6 ) var_h = 0;      //H must be < 1
    var_i = int( var_h ) ;            //Or ... var_i = floor( var_h )
    var_1 = V * ( 1 - S );
    var_2 = V * ( 1 - S * ( var_h - var_i ) );
    var_3 = V * ( 1 - S * ( 1 - ( var_h - var_i ) ) );

    if      ( var_i == 0 ) {
      var_r = V     ;
      var_g = var_3 ;
      var_b = var_1 ;
    }
    else if ( var_i == 1 ) {
      var_r = var_2 ;
      var_g = V     ;
      var_b = var_1 ;
    }
    else if ( var_i == 2 ) {
      var_r = var_1 ;
      var_g = V     ;
      var_b = var_3 ;
    }
    else if ( var_i == 3 ) {
      var_r = var_1 ;
      var_g = var_2 ;
      var_b = V     ;
    }
    else if ( var_i == 4 ) {
      var_r = var_3 ;
      var_g = var_1 ;
      var_b = V     ;
    }
    else                   {
      var_r = V     ;
      var_g = var_1 ;
      var_b = var_2 ;
    }

    R = (1-var_r) * 255;                  //RGB results = 0 ÷ 255
    G = (1-var_g) * 255;
    B = (1-var_b) * 255;
  }
}

void loop()
{
  fog = analogRead(3);
  fog1 = map(fog, 0, 1023, 0, 100);
  Serial.println(fog1);
  analogWrite(3, fog1);
  
  rot = analogRead(1);
  rot1 = map(rot, 0, 1023, 0, 255);
  analogWrite(5, rot1);
  
  lig = analogRead(0);
  h = ((float)lig)/1024;
  h_int = (int) 360*h;
  h2rgb(h, redvar, greenvar, bluevar);
  analogWrite(R, redvar);
  analogWrite(G, greenvar);
  analogWrite(B, bluevar);
  
  upd = analogRead(4);
  if (upd > 1000) {
    digitalWrite(12, HIGH);
  }
  else {
    digitalWrite(12, LOW);
  }
  
  stp = analogRead(2);
 
}

Cheers,
Dan

I see no reason why you can't do this in your code.
Simply add variables for what the values were when the stop button is pressed, and when the value of the pot changes from that value, have it turn on again.

Hope this helped.