]> git.piffa.net Git - arduino/blob - books/ArduinoNextSteps-master/ArduinoNextSteps/sketch_08_01_OneWire_List/sketch_08_01_OneWire_List.ino
first commit
[arduino] / books / ArduinoNextSteps-master / ArduinoNextSteps / sketch_08_01_OneWire_List / sketch_08_01_OneWire_List.ino
1 // sketch_08_01_OneWire_List
2
3 #include <OneWire.h>
4
5 OneWire bus(10);
6
7 void setup()
8 {
9   Serial.begin(9600);
10   byte address[8]; // 64 bits
11   while (bus.search(address))
12   {
13     for(int i = 0; i < 7; i++) 
14     {
15       Serial.print(address[i], HEX);
16       Serial.print(" ");
17     }
18     // checksum OK or Fail
19     if (OneWire::crc8(address, 7) == address[7])
20     {
21       Serial.println(" CRC OK");
22     }
23     else
24     {
25       Serial.println(" CRC FAIL");
26     }
27   }
28 }
29
30 void loop()
31 {
32 }