Hello I need help on my code... I modified the USBHIDBootKbd code from usb host shield 2.0 library to use the data read by the barcode scanner by applying conditions... the serial monitor will display "OK" if the barcode is exact and "Error" if not... but the serial monitor will only display "OK" on the first scan and the rest scans of the same barcode are "Error" ... can you help me display "OK" continously on the rest of the scans? I attached my code below... thank you in advance...
I suggest printing data_count so you can see what is happening after the first read.
void KbdRptParser::OnKeyPressed(uint8_t key)
{
Serial.print("data_count "); Serial.println(data_count);
Data[data_count] = (char)key;
data_count++;
while(data_count !=0)
{ ,
Data[data_count--] = 0;
}
What is that comma doing there?
You don't seem to understand what NULL terminated means. How many NULLs are needed in the array for it to be NULL terminated? Any answer other than one is wrong.
There is no reason to fill the array with NULLs. Put ONE NULL at position 0 and set data_count to 0.
Every time you add a character to the array, add a NULL.
sorry it was push when I entered the code