Created
December 23, 2017 13:55
-
-
Save lazytomatolab/2eab0d245b8f97b0dbbb8475431bf746 to your computer and use it in GitHub Desktop.
【Arduino SpeedUp】快速上手 Class 12 - 分類帽 switch case 降臨!更多資訊請造訪:http://www.lazytomatolab.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
Serial.begin(115200); | |
} | |
void loop() { | |
if(Serial.available()) { | |
int num = Serial.parseInt(); | |
switch(num) { | |
case 1: | |
Serial.println("A"); | |
break; | |
case 2: | |
Serial.println("B"); | |
break; | |
case 3: | |
Serial.println("C"); | |
break; | |
case 4: | |
Serial.println("D"); | |
break; | |
case 5: | |
Serial.println("E"); | |
break; | |
default: | |
Serial.println("Invalid number"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment