Hi,
this code for reading RFID card and send reading to serial port, It was working very well, I added new sub to generate audible confirmation, but I have got incorrect output. any ideas?
Thanks
this code for reading RFID card and send reading to serial port, It was working very well, I added new sub to generate audible confirmation, but I have got incorrect output. any ideas?
B4X:
private Sub ReadRFID(Buffer() As Byte)
Dim tmpBuffer () As Byte
Dim Str_HexNumber As String
Dim Int_Number As ULong
If BC.ArrayCompare(Buffer,BufferLast) = 0 Then 'compare last read card to recent one
Return
End If
tmpBuffer= BC.SubString2(Buffer,1,11) 'get card bytes only, get ride of checksum and start byte
Str_HexNumber = BC.StringFromBytes(tmpBuffer)
Int_Number = Bit.ParseInt(Str_HexNumber, 16) 'convert hex to decimal string
Log(NumberFormat (Int_Number,10,0))
BC.ArrayCopy(Buffer,BufferLast) 'copy last read to recent one, for next comparison
NoReadingTimerTicks = 0 'reset timer
BeepConfirm 'errors came after adding this
End Sub
private Sub NoReadingTimer_Tick()
NoReadingTimerTicks = NoReadingTimerTicks + 1 'avoid reading same card withing 5 seconds
Select NoReadingTimerTicks
Case 5 'reset comparison array
Dim m As Byte
For m = 0 To 13
BufferLast(m) = 0
Next
NoReadingTimerTicks = 0
End Select
End Sub
private Sub BeepConfirm()
Buzzer.DigitalWrite (True)
Delay(50)
Buzzer.Digitalwrite(False)
Delay(25)
Buzzer.DigitalWrite (True)
Delay(50)
Buzzer.Digitalwrite(False)
End Sub
Thanks