Switch Case Statement
Step 1 - Build the Project
The "switch case" statement 'picks' a code statement to run based on the value of a variable. You can create many unique conditions depending on what the variable value is without using many if-else if statements.
Note on serial monitor: first click "Upload to Maker Board", complete the upload, then click the "Monitor" button. A serial monitor will open just below the code window. This allows the data to be sent from the Maker Board to the serial monitor.
Step 2 - Upload the Code
Step 3 - Read the Walkthrough
This is a useful tool when your variable will have one of a fixed set of values and you want to do something different based on each value.
Instead of using many different if- else if statements together, the switch doesn't test each condition, but jumps directly to its match and runs the code.
If you don't include a break; statement after each case, the switch case statement will run every case until it hits a break or finishes the statements.