UNO doesn't recognise SerialSend communication

Hi. I've made an arduino project for my photo booth. The code should turn on and off a LED .
When I use the command SerialSend.exe /devnum 05 /baudrate 9600 'a' or SerialSend.exe /devnum 05 /baudrate 9600 'b' the rx led shows it has communication but the led doesn't turn on .
This is the code that I used:

#include <SoftwareSerial.h>

SoftwareSerial PC(10, 9);

const byte ledPin = 13;

void setup()
{
  Serial.begin(9600);
  PC.begin(38400);
  pinMode(ledPin, OUTPUT);
  Serial.println("starting up");
}

void loop()
{
  if (PC.available())
  {
    static byte ledState = LOW;
    char inChar = PC.read();
    if (inChar == 'a')
    {
      ledState = HIGH;
    }
    else if (inChar == 'b')
    {
      ledState = LOW;
    }
    digitalWrite(ledPin, ledState);
  }
}

This is the serial send program:

SerialSend.exe /devnum 05 /baudrate 9600 'a'
SerialSend.exe /devnum 05 /baudrate 9600 'b'

PC.begin(38400);

Looks like a baud rate mismatch.
Try
PC.begin(9600);

Welcome to the forum

That is strange. Which pins is your serial input connected to ?

1 Like

Sorry, I'm new to arduino but I think the answer is that it is connected via the usb-b to the computer .

I've tried it and it's the same

It appears that you are using the usb serial and not software serial for input. I think you should eliminate the software serial instance, and just use Serial.
Why do you have the software serial instance in your code?

//#include <SoftwareSerial.h>

//SoftwareSerial PC(10, 9);

const byte ledPin = 13;

void setup()
{
  Serial.begin(9600);
  //PC.begin(38400);
  pinMode(ledPin, OUTPUT);
  Serial.println("starting up");
}

void loop()
{
  if (Serial.available())
  {
    static byte ledState = LOW;
    char inChar = Serial.read();
    if (inChar == 'a')
    {
      ledState = HIGH;
    }
    else if (inChar == 'b')
    {
      ledState = LOW;
    }
    digitalWrite(ledPin, ledState);
  }
}

Is your PC in some way connected to pins 10 and 9? Because that is what your code uses. Or is COM5 the USB port that is also used for upload?

The RX led should NOT light up when communicating over SoftwareSerial, so i suspect that you're talking to the USB port of the Arduino and not the SoftwareSerial port.

I'm using an UNO R3 ATMEGA328P

I noticed that too late :frowning:

It worked. Thx a bunch.

Sorry for wasting your time, but i've been hitting my head over this for quite some hours and I didnt know what was wrong and there were almost no examples on this topic.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.