@kemjasonwang, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project
See About the Installation & Troubleshooting category.
Please post your sketch in a post, not as an attachment; please properly ident it in the IDE. Done it this time for you.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(6, 7); // RX, TX
byte STX = 0x02; //STX=02h
byte ETX = 0x03; //ETX=03h
byte CR = 0x0D; //CR=0Dh
byte LF = 0x0A; //LF=0A
byte EOT = 0x04;
byte NUL = 0x0;
byte SOH = 0x1;
byte ENQ = 0x5;
byte ACK = 0x6;
byte BEL = 0x7;
byte BS = 0x8;
byte HT = 0x9;
byte VT = 0xB;
byte FF = 0xC;
byte SO = 0xE;
byte SI = 0xF;
byte DLE = 0x10;
byte DC1 = 0x11;
byte DC2 = 0x12;
byte DC3 = 0x13;
byte DC4 = 0x14;
byte NAK = 0x15;
byte SYN = 0x16;
byte ETB = 0x17;
byte CAN = 0x18;
byte EM = 0x19;
byte SUB = 0x1A;
byte ESC = 0x1B;
byte FS = 0x1C;
byte GS = 0x1D;
byte RS = 0x1E;
byte US = 0x1F;
byte y = 0x30;
byte A = 0x41;
byte R = 0x52;
byte H = 0x48;
byte U = 0x55;
byte start = 0;
void setup() {
Serial.begin(9600);
Serial.println("USB Serial is up and running");
mySerial.begin(4800);
mySerial.write(0x30);
mySerial.write(0x02);
mySerial.write(0x55);
mySerial.write(0x32);
mySerial.write(0x0D);
mySerial.write(0x0A);
mySerial.write(0x0D);
mySerial.write(0x0A);
mySerial.write(0x04);
}
void loop() {
mySerial.println("STX");
mySerial.println("A");
mySerial.println("ETX");
if (mySerial.available()) {
Serial.println(mySerial.read());
}
}
mySerial.println("STX") will send the word STX (so 3 characters), not the character STX (hex 0x02) that's at the beginning of your code. It also sends a <CR><LF>.
Use mySerial.write(STX); and so on for a start (like you did in setup()).
What happens with this code?
#include <SoftwareSerial.h>
void setup()
{
Serial.begin(9600);
Serial.println("USB Serial is up and running");
mySerial.begin(4800);
mySerial.write(0x30);
mySerial.write(0x02);
mySerial.write(0x55);
mySerial.write(0x32);
mySerial.write(0x0D);
mySerial.write(0x0A);
mySerial.write(0x0D);
mySerial.write(0x0A);
mySerial.write(0x04);
}
void loop()
{
if (mySerial.available()) {
Serial.write(mySerial.read());
}
}
Do you get a reply from the device?
Note:
I did not dig too deep into the manual.