I don’t know much about Arduino yet.
I have modified a program so that a relay is switched. I would use this to open the gate.
But now the key number is on the serial moitor but would like to change it to name, how can you do this?
So think there must be a reference that the address of key1 has a name eg bob.
Best regards
#include <OneWire.h>
// ID's van twee iButton-sleutels
byte key1[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDC}; // 00 00 00 00 01 00 00 DC
byte key2[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54}; // 00 00 00 00 01 00 00 54
int pinNumber = 2;
OneWire ds(pinNumber);
void setup() {
pinMode(3, OUTPUT);
Serial.begin(9600);
}
void loop() {
byte addr[8];
byte val1 = 0;
byte val2 = 0;
delay(1000);
if (ds.search(addr)) {
Serial.print("#");
for (int i=0; i<8; i++) {
Serial.print(" ");
Serial.print(addr[i], HEX);
// 1key
if (addr[i] == key1[i]) val1++;
// 2 key
if (addr[i] == key2[i]) val2++;
}
Serial.print("@");
Serial.println("");
ds.reset_search();
}
if (val1 == 8) {
digitalWrite(3, HIGH);
delay(1000);
digitalWrite(3, LOW);
}
if (val2 == 8) {
digitalWrite(3, HIGH);
delay(500);
digitalWrite(3, LOW);
}
}