Advertisement
Guest User

Untitled

a guest
May 21st, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <OneWire.h
  2. const byte ONEWIRE_PIN = 2;
  3. OneWire onewire(ONEWIRE_PIN);
  4. void setup() {
  5. while(!Serial);
  6. Serial.begin(9600);
  7.  }
  8. void loop() {
  9. byte address[8];
  10. onewire.reset_search();
  11.  while(onewire.search(address)) {
  12.    if (address[0] != 0x28)
  13.   continue;
  14.    if (OneWire::crc8(address, 7) != address[7]) {
  15.   Serial.println(F("Błędny adres, sprawdz polaczenia"));
  16.   break;
  17.    }
  18.   for (byte i=0; i<8; i++) {
  19.   Serial.print(F("0x"));
  20.    Serial.print(address[i], HEX);
  21.   if (i < 7)
  22.   Serial.print(F(", "));
  23.   }
  24.   Serial.println();
  25.   }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement