Im new to this and need a little help
im setting up a rfid lock for my car with two relays
relay1 lock
relay2 unlock
i need it to switch back and forth
for example i put card to reader it pulses relay1 to lock the doors i put card to reader again this time to pulse relay2 to unlock the doors
please help!!!
this is my current code to auto relock the doors after a delay but i dont want auto relock
digitalWrite(relay2, LOW); // Unlock door!
delay(500); // pulse relay for Milli seconds
digitalWrite(relay2, HIGH);
delay(5000); //delay before relock
digitalWrite(relay1, LOW); // Relock door
Which RFID reader have you got ?
RC522
all the rfid coding is done i just need help with the relay coding
i just need help with the relay coding
Where are you stuck ? You obviously how to turn a relay on and off so what is the problem ?
my problem is the relays i want them to switch each time the card is read (put card to reader relay1 pulses put card to reader again relay2 pulses)
Ok. How about coding it like this pseudo code ?
cardReadOnce = false
start of loop()
if a card is detected
if cardReadOnce is false
set cardReadOnce to true
pulse relay 1
end if
else
pulse relay 2
set cardReadOnce to false
end else
end if
end of loop()
There are neater ways to do it but this is easy to understand