Serial Read Digital output

Completely new to coding and I'm wanting to read weigh scales from tx pin and output a HIGH on pin 13 (Ledbuiltin)
So far I am reading SoftwareSerial with the code below.

#include <SoftwareSerial.h>

#define rxPin 3
#define txPin 4

SoftwareSerial softSerial(rxPin, txPin);

void setup() {

softSerial.begin(9600);

Serial.begin(9600);
}

void loop() {
byte n = softSerial.available();
if(n!=0)
{
char data = softSerial.read();
Serial.print(data);
}

....and?

Please remember to use code tags when posting code

Tell us more . . .

What hardware do you have ?


Show us a good schematic of your circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.


In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.
Use the </> icon from the ‘reply menu’ to attach the copied sketch.

Using components below
10kg Load cell with HX711 and built in screen Amazon
Nano
5V relay
24vdc Solenoid valve

It is for filling small buckets with liquid. I'm wanting to open the solenoid valve when the empty bucket is placed on the scale and stop filling when the weight reaches a preset level.

#include <SoftwareSerial.h>

#define rxPin 3
#define txPin 4

SoftwareSerial softSerial(rxPin, txPin);

void setup()  {

  softSerial.begin(9600);

  Serial.begin(9600);
}

void loop() {
  byte n = softSerial.available();
  if (n != 0)
  {
    char data = softSerial.read();
    Serial.print(data);
  }

}

Have a look at the example sketches in Arduino Serial – Reading/Parsing for ways to read data from Serial (and SoftwareSerial) and parse it.
There are pros/cons for each example given

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