title: Using switch to select a case with pushbutton -- toggle
body: <p>I am working on a toggle using switch case. Not sure if I'm doing it right. My intention should be fairly obvious through my code example.</p>
  
  <p>I want to increment a counter with a pushbutton use the x++ function and some toggle code I have saved that should be usable in a switch(case) statement to produce desired outcomes at a particular case by toggling an output pin on upon case selection and off when case is no longer valid. Each case would have its own output pin with a specific case loop to execute when that case becomes valid. I can write the output loops once I get the toggle mode working. There are some missing pieces to the code. I have no formal coding experience and have only taught myself a little bit here and there. I've started with my Basic Stamp Homework Board and switched over from BS2 to Arduino. My goal is to compile the codes that I need for basic projects and save it. Then I can realistically be done with base-coding and focus on connecting hardware and fine-tuning the hardware:software. </p>
  
  <p>Not quite sure how to use this switch function. Wondering if I need to have a FOR statement somewhere in there to increment my counter. Was thinking I could increment the counter each time the toggle1 value flipped or something to that effect. Another though would be to utilize switch(case) by modulo, toggling case values by pressing the button a specific number of times. 1 press would be case 1, 2 press -- case 2, 3 press -- case 3, etc... Case 0 could be 5  presses and be the last cycle using the ++x operator. Toggling case using pushbutton and ++ should be a very very simple matter. I have very little experience with programming. Would like some guidance. I hope that the gist of my idea is all in the code. Thank you. </p>
  
  <pre><code>const int btn = 22;
  const int led = 3;
  int selector1 = i;
  int btnValue = digitalRead(btn);
  int i = 0;
  
  
  bool isPressed = false;
  
  
  if (btnValue == LOW &amp;&amp; isPressed == false){
      i = i++;
  
      if (i &gt; 3){
          i = 0;
      }
  }
  
  {
      switch(case){
  
          case 1:
  
          selector1 == 0;
          do digitalWrite(led, HIGH);
          Serial.println(digitalRead(23));
          break;
  
          case 2:
  
          selector1 == 1;
          do digitalWrite(13, HIGH);
          Serial.println(digitalRead(13));
          break;
  
          case 3:
  
          selector1 == 2; 
  
          do digitalWrite(4, HIGH);
          Serial.println(digitalRead(4));
          break;
  
          case 4:
  
          selector1 == 3
  
          do digitalWrite(5, HIGH);
          Serial.println("You've reached the last selection.");
          Serial.println(digitalRead(5));
      }
  }
  </code></pre>