Arduino-OWI
One-Wire Interface (OWI) library for Arduino
DS1990A.ino
Go to the documentation of this file.
1 #include "GPIO.h"
2 #include "OWI.h"
3 #include "Software/OWI.h"
4 
5 GPIO<BOARD::D13> led;
7 
8 // Table with valid keys (64 bit 1-Wire rom code, 8 bytes per entry)
9 const uint8_t KEY[] PROGMEM = {
10  0x01, 0x23, 0x81, 0xa3, 0x09, 0x00, 0x00, 0x7b,
11  0x01, 0x29, 0x01, 0x27, 0x09, 0x00, 0x00, 0xa8,
12  0x01, 0x26, 0xd9, 0x3e, 0x09, 0x00, 0x00, 0x47
13 };
14 
15 void setup()
16 {
17  led.output();
18  led = LOW;
19 }
20 
21 void loop()
22 {
23  // Attempt to read key every seconds
24  uint8_t rom[owi.ROM_MAX] = { 0 };
25  delay(1000);
26  if (!owi.read_rom(rom)) return;
27 
28  // Check if it is an authorized key. One long blink if found
29  for (uint8_t i = 0; i < sizeof(KEY); i += OWI::ROM_MAX) {
30  if (!memcmp_P(rom, &KEY[i], owi.ROM_MAX)) {
31  led = HIGH;
32  delay(1000);
33  led = LOW;
34  return;
35  }
36  }
37 
38  // Three short blinks if not found
39  for (uint8_t i = 0; i < 3; i++) {
40  delay(250);
41  led = HIGH;
42  delay(250);
43  led = LOW;
44  }
45 }
void setup()
Definition: DS1990A.ino:15
Software::OWI< BOARD::D1 > owi
Definition: DS1990A.ino:6
const uint8_t KEY[]
Definition: DS1990A.ino:9
void loop()
Definition: DS1990A.ino:21
bool read_rom(uint8_t *code)
Definition: OWI.h:222
GPIO< BOARD::D0 > led
Definition: DS1990A.ino:5
static const size_t ROM_MAX
Definition: OWI.h:32