Skip to content

Commit 6b15f79

Browse files
committed
ECCX08 monotonic counter example sketch
1 parent 6ced7ec commit 6b15f79

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
ECCX08 Counter
3+
4+
This sketch uses the ECC508 or ECC608 to increment a monotonic
5+
counter at each startup
6+
7+
Circuit:
8+
- Any board with ECC508 or ECC608 on board
9+
10+
*/
11+
12+
#include <ArduinoECCX08.h>
13+
14+
const int keyId = 5;
15+
long counter = -1;
16+
17+
void setup() {
18+
Serial.begin(9600);
19+
while (!Serial);
20+
21+
if (!ECCX08.begin()) {
22+
Serial.println("Failed to communicate with ECC508/ECC608!");
23+
while (1);
24+
}
25+
26+
if (!ECCX08.incrementCounter(keyId, counter)) {
27+
Serial.println("Failed to increment counter");
28+
while (1);
29+
}
30+
}
31+
32+
void loop() {
33+
if (!ECCX08.readCounter(keyId, counter)) {
34+
Serial.println("Failed to read counter");
35+
while (1);
36+
}
37+
38+
Serial.print("Counter value = ");
39+
Serial.println(counter);
40+
41+
delay(1000);
42+
}
43+

0 commit comments

Comments
 (0)