-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArduinoPinChecker.ino
63 lines (57 loc) · 1.14 KB
/
ArduinoPinChecker.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
61
62
63
// Config
int delayMilliseconds = 3000;
typedef struct
{
const char *name;
uint8_t *value;
} pinArray;
const pinArray analogPins[] = {
{"A0", A0},
{"A1", A1},
{"A2", A2},
{"A3", A3},
{"A4", A4},
{"A5", A5}};
const pinArray digitalPins[] = {
{"0", 0},
{"1", 1},
{"2", 2},
{"3", 3},
{"4", 4},
{"5", 5},
{"6", 6},
{"7", 7},
{"8", 8},
{"9", 9},
{"10", 10},
{"11", 11},
{"12", 12},
{"13", 13}};
void setup()
{
Serial.begin(9600);
}
template <typename Func>
void printData(const pinArray *pins, size_t size, Func function)
{
// Serial.print(">>");
// Serial.println(digitalRead(3));
for (size_t i = 0; i < size; i++)
{
Serial.print(pins[i].name);
Serial.print(": ");
Serial.print(function(pins[i].value));
Serial.println();
}
}
void loop()
{
for (int i = 0; i < 10; i++)
{
Serial.print("-");
}
Serial.println();
printData(analogPins, sizeof(analogPins) / sizeof(pinArray), analogRead);
printData(digitalPins, sizeof(digitalPins) / sizeof(pinArray), digitalRead);
delay(delayMilliseconds);
}