Read serial flow USB - Arduino Uno / Windows 10

I use Autohotkey to read/write data from/to an Arduino Uno (and the joystick Shield V1.0A - Fundurino).
My problem is - How to know that the data is correct.
I got many read error when the data is read faster than 9600bps.

This is a result from my AHK program .:
Buttons A:1 B:1 C:1 D:1 E:1 F:1 -- Position X:334 Y:322
334 Y:322
Buttons A:1 B:1 C:1 D:1 E:1 F:1 -- Position X:334 Y:322
Buttons A:1 B:1 C:1 D:1 E:1 F:1 -- Position X:334 Y:322
Buttons A:1 B:1 C:1 D:1 E:1 F:1 -- Position X:335 Y:322

When buttons are pressed on the joystick card, read errors can easily occur.

The goal is to be able to read / write to the Arduino Uno with a PC - Windows, and be sure that the desired data is transmitted.

This is my program in the Arduino

// Arduino --- Funduino Joystick Shield ---
// Playlist:
// Part 1. Introduction - Basic Functions:

// Arduino digital pins associated with buttons
const byte PIN_BUTTON_A = 2; 
const byte PIN_BUTTON_B = 3;
const byte PIN_BUTTON_C = 4;
const byte PIN_BUTTON_D = 5;
const byte PIN_BUTTON_E = 6;
const byte PIN_BUTTON_F = 7;

// Arduino analog pins associated with joystick
const byte PIN_ANALOG_X = 0;
const byte PIN_ANALOG_Y = 1;

void setup() {

  pinMode(PIN_BUTTON_B, INPUT);  
  digitalWrite(PIN_BUTTON_B, HIGH);
  pinMode(PIN_BUTTON_E, INPUT);  
  digitalWrite(PIN_BUTTON_E, HIGH);
  pinMode(PIN_BUTTON_C, INPUT);  
  digitalWrite(PIN_BUTTON_C, HIGH);
  pinMode(PIN_BUTTON_D, INPUT);  
  digitalWrite(PIN_BUTTON_D, HIGH);
  pinMode(PIN_BUTTON_A, INPUT);  
  digitalWrite(PIN_BUTTON_A, HIGH);  

void loop() {
  Serial.print("Buttons A:");
  Serial.print(" ");
  Serial.print(" ");
  Serial.print(" ");
  Serial.print(" ");

  Serial.print(" ");
  Serial.print(" -- ");
  Serial.print("Position X:");
  Serial.print(" ");
  Serial.print(" ");  

Before you going bananas and try this and that, you need to study the data and determine EXACTLY what the error is and if it is consistent. Is it always one bit in the third byte of a message? OR are characters added to your original message? Or are characters missing?

You can't correct an error unless you know what the error is.

Once you have a handle on the error, then there are ways to either correct it or cause a re-transmission of the message.

Either way, the fix has to be applied to both the sender and the receiver software.


Thanks! I'm a complete beginner with Arduino Uno

My wish (right now) is to be able to read the status of various ports / buttons on the Arduino UNO (with the joystick card connected).
The big problem is that I don't know how to communicate with the Arduino, with a program in the PC (in my case Autohotkey). If I use the serial monitor for the Arduino - it seems to work. (no problem...)

I do not receive any error message from Arduino or Autohotkey.
My problem is - How do i know that the data from Arduino is accurate.
If I only read once, I got eg. But:322 (some information is missing)
Next time I read the "message" from the Arduino I get eg. Buttons A:1 B:1 C:1 D:1 E:1 F:1 -- Position X:334 Y:322 (i.e. expected information)
the third time Arduino is read with AHK I got eg. 334 Y:322 (some information is missing)
The fourth time the information may be correct again.

If autohotkey reads from Arduino 100 times I usually only get maybe 30 results.
Now that the serial port is running 9600 bps. The result is much better than running serial communication at faster speeds.

Does there have to be some sort of handshake between the PC and Arduinon?
Must the data be read several times and be compared?

Is this something you have to accept?

Seems to me the autohotkey program has to know how to identify the beginning of a message from the Arduino, and the end of a message. What is it expecting? When you know that, then you can generate the correct messages.



The program that runs in the Arduino looks like this .:

void setup() {

void loop(){
  while (Serial.available() > 0) {

When the Autohotkey program is started, a header is sent from my PC to the Arduino .: - - - - - - TERMINAL OUTPUT - - - - - -

The Arduino send directly back to the PC .: ðð- - - - - - TERMINAL OUTPUT - - - - - -
(If the baud rate is higher than 9600) - 0xF0 0xF0 at the beginning of the desired string. I don’t know where this characters is coming from. (as the attached example)

But these characters never come back, even if I press “BackSpace” and clear the text in the GUI-window and send the header again to the Arduino.

Is there anything unknown that needs to be cleared in Arduino serial buffer? (How to know?)
But, I think these characters (always the same characters) would also be created at 9600bps…


Your Arduino is reset when the PC program opens to connection. How long after opening the serial connection does your PC program wait?


OK! (thanks!)

I initiate communication with Arduino and send the headline (as HEX) without delay.
Have tried adding delays of 1-2 seconds, after initializing the COM port.
But I have not seen any change in the result being sent back from Arduino.

At different baud rates, the results are different. With 115200 baud, two ðð are created before the heading, while a baud rate of 19600 only creates the following characters ý before the heading.

Wonder if it would be difficult to mirror the contents of the serial buffer to an LCD display on the Arduino. (I'm not very good at Arduino UNO - language)

Have tried writing a program for Arduino UNO that both sends characters back to PC and at the same time sends characters to an I2C LCD Display 16x2 characters - Baudrate .: 115200.

Maybe this can solve where the unwanted characters come from.

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C LCD(0x27, 16, 2);  // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup() {
  while (!Serial) {
    }  // Wait for serial port to connect. For native USB port only
  LCD.init();       // initialize the lcd 
  LCD.backlight();  // The BackLight ON

void loop(){
  while (Serial.available() > 0) {
    int Char =;
    LCD.write(Char);      // Write the read characters to the display
    Serial.write(Char);   // Send the read characters back to the PC

Example1 .:
I send “TERMINAL” LineFeed “>>” from the PC to the Arduino.
I got back to the PC .: ððTERMINAL LineFeed >> (as before)
On the LCD I got the result (as attached image) -
Can anyone explain why?

Is there a structural error?
What I send to Arduinon is, as I said, the text "TERMINAL" CHR(10) ">>"

But before this is sent through USB to the Arduino, the text is converted to HEX as in this example the result was .: 0x54,0x45,0x52,0x4D,0x49,0x4E,0x41,0x4C,0xA,0x3E,0x3E

Is this wrong?
Should it be without comma and only HEX? (like this 5445524D494E414C0A3E3E)

Because the problem persists, I began to change the communication settings.

I first changed parity from none to odd - but apparently the unwanted characters remain, which occur when the terminal program on the PC is started..

But, when the parity was set to "even", I couldn't provoke junk characters at the baud rate of 115200 bps, (But with 19200 I got junk characters in almost all tests.)

Is there any suggestion why it could be this way?