-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDS2401.ino
More file actions
44 lines (33 loc) · 1003 Bytes
/
DS2401.ino
File metadata and controls
44 lines (33 loc) · 1003 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
44
// DS2401 Changes by: Seyed roohollah Marashi Iran -Tehran 2020
// DS2401 is unique Transistor, IC or Chip or memory
// Coming with Constant Serial Number That we Can Depend
// Running program to This Uniq Serial Availability or other Usages
// in case of any changes for this serial we are able to clean all
// EPROMS OR EXTERNAL MEMORIES to keep safe Programmed device
#include <OneWire.h>
OneWire net(10); // on pin 10
void PrintBytes(const uint8_t* addr, uint8_t count, bool newline=false) {
for (uint8_t i = 0; i < count; i++) {
Serial.print(addr[i]>>4, HEX);
Serial.print(addr[i]&0x0f, HEX);
}
if (newline)
Serial.println();
}
void setup(void) {
Serial.begin(9600);
}
void loop(void) {
byte addr[8] = {0};
if (!net.search(addr)) {
Serial.print("------------------------\n");
net.reset_search();
delay(1000);
return;
}
if (addr[0] != 0x29) {
PrintBytes(addr, 8);
Serial.print(" is Uniqu code of your DS2401.\n");
return;
}
}