forked from IELS1001-23-24/programming-course
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fallthrough.ino
60 lines (48 loc) · 933 Bytes
/
fallthrough.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Fix the code so only one letter is printed per number.
// 3, 4 and 5 should print the letter D once.
// Hint:
// https://www.w3schools.com/js/js_switch.asp
// https://stackoverflow.com/questions/8146106/does-case-switch-work-like-this
void printValue(int value)
{
Serial.print(value);
Serial.print(": ");
switch (value)
{
case 0:
Serial.print("A");
case 1:
Serial.print("B");
case 2:
Serial.print("C");
break;
case 3:
case 4:
case 5:
Serial.print("D");
default:
Serial.print("E");
}
Serial.println("");
}
void setup()
{
Serial.begin(9600);
printValue(0);
delay(1000);
printValue(1);
delay(1000);
printValue(2);
delay(1000);
printValue(3);
delay(1000);
printValue(4);
delay(1000);
printValue(5);
delay(1000);
printValue(6);
delay(1000);
}
void loop()
{
}