Hello. Can anyone help with my code? I need to receive 1 or 0 from C# program running on my pc using ENC28J60 to lock or unlock door (access control system). I am using EtherCard library. The listening part should be in the big gap that I left. At the moment I am able to read card's UID, send it to C#, check database entries and probably send the 1 or 0 (the code for sending 1 or 0 from C# is bellow) back to Arduino. But I have no idea if the C# sending part is working, since I can't check the Arduino part. So can anyone help me?
C# sending part:
byte[] answer1 = Encoding.ASCII.GetBytes("1");
handlerSocket.Send(answer1);
Arduino part:
void loop () {
normalModeOn();
ether.packetLoop(ether.packetReceive());
uid = "";
if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial())
{
for (int i = 0; i < 4; i++)
{
if (mfrc522.uid.uidByte[i] < 0x10)
uid += "0";
uid += String(mfrc522.uid.uidByte[i], HEX);
}
delay (100);
Serial.println(uid);
Stash stash;
byte sd = stash.create();
stash.print(uid);
stash.print("/r");
stash.save();
Stash::prepare(PSTR("$H"), sd);
ether.tcpSend();
Serial.println("Packet sent!");
Serial.println();
//openDoor();
mfrc522.PICC_HaltA();
delay(100);
}
}