File read from SDCard & HID Keyboard press demo prints 'unexpected' characters

Hi Everyone! I'm pretty new to Arduino & need your expert suggestions on a issue i'm facing with my arduino project.

I'm trying to read file content from Arduino & convert them as HID key code & simulate key press. i'm getting the desired result with my project. however, if the following line in is removed then the complete code doesn't work.

Serial.println("\n");

but, if the above line is added then HID simulation starts with below combination of additional keypress before it start printing the characters read form SDcard file.


g

e.g:-

file content :- B B ROY goes to Great Britain to find a Very Good Wife.

Expected HID keyboard simulation:- B B ROY goes to Great Britain to find a Very Good Wife.

if the line "..Serial.println("\n");.." is added in the code then,

Actual HID keyboard simulation:- gB B ROY goes to Great Britain to find a Very Good Wife.

What can i do in my code to avoid those unexpected additional keypress from my code..

sdcard-read-hid-press.txt (10.7 KB)

Which Arduino are you using? Looks like a modified Uno/Mega. If so, I don't think that I can help but others might be.

I'm using UNO V3 for this project.. Any specific model which i can try to avoid this problem

An Uno can't act as a HID unless you modify the firmware in the 8U2 / 16U2.

If you really need HID functionality, get something like a Leonardo, Micro or ProMicro.

i have already flashed the required LUFA firmware to make UNO (16U2) act as HID keyboard.. It can actually read the file content from SDcard & prints the characters on notepad as how actual keyboard does..

However, the problem is that the code (i attached in this post) which reads SDcard file contents & convert them as HID keycodes to simulate keyboard pressing, prints below unexpected characters, if this line "..Serial.println("\n");.." is added in the code.


g

As I said in the first reply, I can't help with a modified Uno.

I hope somebody else comes along.