Skip to content

Instantly share code, notes, and snippets.

@lazytomatolab
Created December 23, 2017 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazytomatolab/2eab0d245b8f97b0dbbb8475431bf746 to your computer and use it in GitHub Desktop.
Save lazytomatolab/2eab0d245b8f97b0dbbb8475431bf746 to your computer and use it in GitHub Desktop.
【Arduino SpeedUp】快速上手 Class 12 - 分類帽 switch case 降臨!更多資訊請造訪:http://www.lazytomatolab.com
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