forked from arduino-libraries/ArduinoECCX08
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathECCX08Counter.ino
More file actions
44 lines (32 loc) · 824 Bytes
/
ECCX08Counter.ino
File metadata and controls
44 lines (32 loc) · 824 Bytes
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
/*
ECCX08 Counter
This sketch uses the ECC508 or ECC608 to increment a monotonic
counter at each startup.
Circuit:
- Any board with ECC508 or ECC608 on board
*/
#include <ArduinoECCX08.h>
// The counter to be incremented. Only zero and one are legal values.
const int counterId = 0;
long counter = -1;
void setup() {
Serial.begin(9600);
while (!Serial);
if (!ECCX08.begin()) {
Serial.println("Failed to communicate with ECC508/ECC608!");
while (1);
}
if (!ECCX08.incrementCounter(counterId, counter)) {
Serial.println("Failed to increment counter");
while (1);
}
}
void loop() {
if (!ECCX08.readCounter(counterId, counter)) {
Serial.println("Failed to read counter");
while (1);
}
Serial.print("Counter value = ");
Serial.println(counter);
delay(1000);
}