Serial Communication issue.

Hi Everyone,
I have been struggling with this:

I am sending data from my Mac computer to my arduino uno via the USB port.
But my Arduino doesn't seem to receive it.

I made the simplest program to troubleshoot and the arduino is still not reacting properly.

void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600);
digitalWrite(13, LOW);
}
void loop() {

if (Serial.available()>0) {digitalWrite(13, HIGH);}
}

The thing is:

I see the TX and RX lights flashing on the board meaning that there is communication going on.
I connected a scope on Pin 0 and ground and I can read the data that I am sending on this port. I can even decode it with the scope and it is proper data.

Why the Arduino is not lighting up the pin 13 LED?
If I force it on it will light up.

On my Mac I set the transmission to be 9600, 8, 0, n and handshake 0

Any ideas?

For the sake of troubleshooting, actually read the serial data and echo it back.

I would love to be able to use the serial monitor for troubleshooting but I soon as I start it, I can't send anything from the computer. it says that the port is busy.

it would be nice if the serial monitor was "transparent".

It might be the problem with the pin 13 led. Try using another pin (don't use 0 and 1). Use pin 10 instead of 13. And connect an external led to pin 10 and run your sketch. You should get a confirmation.

..Arnav

Carib58:
I would love to be able to use the serial monitor for troubleshooting but I soon as I start it, I can't send anything from the computer.

You can send from Serial Monitor.

ArnavPawarAA:
It might be the problem with the pin 13 led.

Did you read what the OP said:

Carib58:
If I force it on it will light up.

Carib58:
On my Mac I set the transmission to be 9600, 8, 0, n and handshake 0

Says here though that the default on the Arduino is 8n1.

8n1.PNG

8n1.PNG

heronclose:
Did you read what the OP said:

Says here though that the default on the Arduino is 8n1.

I meant that the problem can be with the connection between the Led and pin 13.
I think that the problem is with pin 13. Led and output pin 13 are connected with eachother, but the chip's pin 13 isn't connected. That problem might be with the PCB soldering.

..Arnav

That's not the OP's symptom: they're not connecting to the pin, just using the led, which evidently works.

First thing to do is to change the settings on one end so they match.

I would say to the OP to make a continuity test between the chip and Led.

.. Arnav

ArnavPawarAA:
I would say to the OP to make a continuity test between the chip and Led.

The simple way to do that is to blink the LED once or twice in setup()

Carib58:
I would love to be able to use the serial monitor for troubleshooting but I soon as I start it, I can't send anything from the computer. it says that the port is busy.

Do your initial testing with the Serial Monitor only.

...R

Thanks for the many comments... however:

If I just tell the LED to come ON, it will. its working.

I tested another output and it still doesn't work.

If I send something from the serial monitor, it works, the LED come ON.

The comm setting on the sender (my Mac) is bps 9600 bits 8 parity 0 stop bits 1

It could be a configuration issue on the sender but what confuses me is that I am not even asking for the Arduino to decode at this point. I am just asking to activate the output if it sees anything coming on the serial port.

int flag = 13;
void setup() {
pinMode(flag, OUTPUT);
Serial.begin(9600);
digitalWrite(flag, LOW);
}
void loop() {
if (Serial.available()>0) {digitalWrite(flag, HIGH);}
}

Is there another function that I can use instead? Even if it receive garbage?

Could it be related to the serial buffer size?

I tested the sketch on an Uno. It works fine. The LED is off initially, I send some characters from the serial monitor and it turns on. Windows system here.

it would be nice if the serial monitor was "transparent".

Just use a real terminal like Putty or Tera Term.

aarg:
I tested the sketch on an Uno. It works fine. The LED is off initially, I send some characters from the serial monitor and it turns on. Windows system here.Just use a real terminal like Putty or Tera Term.

I know, I tested like that too.

But when I send from my Mac using another software, I get no results even if I see that the transmission occurred, looking at the TX RX lights, and measuring with my scope.

Arduino receives it, mirror it to Pin 0, but I can't make my program work.

Arduino receives it, mirror it to Pin 0, but I can’t make my program work.

?

What happens when you upload a Serial example sketch from the IDE?

Carib58:
Thanks for the many comments… however:

If I just tell the LED to come ON, it will. its working.

I tested another output and it still doesn’t work.

If I send something from the serial monitor, it works, the LED come ON.

The comm setting on the sender (my Mac) is bps 9600 bits 8 parity 0 stop bits 1

It could be a configuration issue on the sender but what confuses me is that I am not even asking for the Arduino to decode at this point. I am just asking to activate the output if it sees anything coming on the serial port.

int flag = 13;
void setup() {
pinMode(flag, OUTPUT);
Serial.begin(9600);
digitalWrite(flag, LOW);
}
void loop() {
if (Serial.available()>0) {digitalWrite(flag, HIGH);}
}

Is there another function that I can use instead? Even if it receive garbage?

You should use this function instead of Serial.available()

Serial.read() != "Elejakqlakn"

The junk text is just something random, but won’t match with the garbage reicieved by the Arduino. Please test this.

… Arnav

ArnavPawarAA:
You should use this function instead of Serial.available()

Serial.read() != "Elejakqlakn"

The junk text is just something random, but won’t match with the garbage reicieved by the Arduino. Please test this.

… Arnav

Are you being serious?

TheMemberFormerlyKnownAsAWOL:
Are you being serious?

Yes, what's wron in the code?

ArnavPawarAA:
Yes, what’s wron in the code?

Serial.read returns an “int”.
Can an “int” equal a string literal?