From the course: Learning Arduino: Interfacing with Hardware

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Optional review: The switch...case statement

Optional review: The switch...case statement - Arduino Tutorial

From the course: Learning Arduino: Interfacing with Hardware

Optional review: The switch...case statement

- [Instructor] All right, so I'm going to go through the switch...case statement. If you are familiar with the concept, you can skip this video, but if you want to refresh your memory about what the concept is, I'm going to go through the concept briefly. So one of the structure commands used within Arduino is a switch...case statement. Oftentimes, we might need to compare a variable against several possible values. For example, the keypad we're using, so we might need to have an assorted output to be associated when we press certain numbers on the keypad. The switch statement uses a standard if...then style condition to evaluate for results. The Arduino jumps to the matching case statement in the code, skipping over the other case statements. You can have a default statement at the end of the switch statement code block. The Arduino software jumps to the default statement when none of the cases matches the results. So…

Contents