Problem sending raw serial data to arduino

Hi everyone,
i am trying to comunicate directly to an atmega328 on an arduino uno using serial TX/RX with a usb to TTL device (with a CH340 ic).

I created a simple sketch that accepts a command on serial port and does things according to the command content.

int inByte = 0;
bool ledPinStatus = 0;

void setup() {

  Serial.println("Setup done");

  pinMode(13, OUTPUT);

void loop() {

  if (Serial.available() > 0) {
    // get incoming byte:
    inByte =;
    if (inByte == 65) {
      if (ledPinStatus == 1) {
        ledPinStatus = 0;
        digitalWrite(13, LOW);
      } else {
        ledPinStatus = 1;
        digitalWrite(13, HIGH);


Everything works if i test it with the usb cable: i get a correct "setup done" message when resetting the arduino and it reacts correctly to the commands i send.
When i connect it to the USB to TTL device (unplug usb and power up arduino from usb-ttl) it only gives the "setup completed" message but does not react to the data i send.
This also happens with other serial/COM monitor utilities such as windows terminal.

I tried configuring the COM settings to 9600 baud (and other values) according to the arduino sketch settings and 8 bit length with no parity.
I also tryed some more configurations and also on Linux but always got the same result.
I have the feeling that the arduino to pc communication works because the device in between is doing all the stuff self configuring but it is not configured when sending data to the arduino.

Maybe it is a matter of configuring the COM port properly...?

I tryed with arduino nano and uno rev.3
i also tryed removing the atmega328 ic from an arduino uno and connecting it to the other arduino (with correct pin tx/rx) and i get same result: "setup done" feedback but cant communicate from pc to arduino.

Any idea what am i missing?
Thanks in advance for any help

Any idea what am i missing?

A little bit of whitespace between your paragraphs so your text is easier to read.

And, most importantly, your code.
Please use the code button </> so your code looks like this and is easy to copy to a text editor


A little update: using SoftwareSerial library and different pins it worked as expected. I just compiled the first example of the library documentation with a little modification to fit my need.

Anyway, the sketch makes compilation fail without an instance of Serial library. Because of this i can't use pin0/1 for serial communications at the moment.