Sub rfid_CardPresent (UID() As Byte, CardType As Byte)
Log("UID: ", bc.HexFromBytes(UID))
Log("Type: ", CardType, ", Is it Mifare: ", rfid.IsMifare)
If rfid.IsMifare Then
If rfid.MifareAuthenticate(1) = False Then
Log("Failed to authenticate")
Return
End If
Dim buffer(18) As Byte
For i = 0 To buffer.Length - 1
buffer(i) = i
Next
'write 16 bytes to block number 1
Log("Write: ", rfid.MifareWrite(1, buffer))
If rfid.MifareRead(1, buffer) > 0 Then 'buffer size must be 18 bytes or more
Log(bc.HexFromBytes(buffer))
Else
Log("Failed to read")
End If
End If
End Sub