trying to do echo test but i only get rubisch on the recieving end
my code look likes this :
#include <SoftwareSerial.h>
int incomingByte = 0;
SoftwareSerial mySerial(10, 11);
char receivedChar;
boolean newData = false;
void setup() {
Serial.begin(115200); // opens serial port, sets data rate to 9600 bps
mySerial.begin(115200);
Serial.println("<Arduino is ready>\r\n");
mySerial.println("<Arduino is ready>\r\n");
char buffer[50];
mySerial.readBytes(buffer, sizeof(buffer));
Serial.println(buffer);
}
void loop() {
recvOneChar();
showNewData();
}
void recvOneChar() {
if (mySerial.available() > 0) {
receivedChar = Serial.read();
newData = true;
}
}
void showNewData() {
if (newData == true) {
Serial.print("This just in ... ");
// mySerial.print("OK");
Serial.println(receivedChar);
while (Serial.available() > 0) {
Serial.read();
}
newData = false;
}
}
the out punt on serial side is of my pc is
<Arduino is ready>
<Arduino is ready>
and on the adrino side:
This just in ... ⸮
This just in ... ⸮
This just in ... ⸮
This just in ... ⸮
This just in ... ⸮
This just in ... ⸮
This just in ... ⸮
This just in ... ⸮
This just in ... ⸮
As mentioned the code is weird, not sure what you are trying to achieve
You could send something to both ports in the setup and the loop could check if there is a byte waiting on a serial port (for both) and print it
Also you should not open the Serial monitor if you use Serial for the loop back so better take Serial1 and Serial2 and keep Serial for showing what’s going on and possibly as a source of text to send from one Serial to the other
So i want send back what was recieved didn't know i could use both pyshcal serial and serial monitor.
en didn't know there where multilple serial interfaces.
so simplify the code now
int incomingByte = 0;
char receivedChar;
boolean newData = false;
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
Serial.println("<Arduino is ready>\r\n");
}
void loop() {
recvOneChar();
showNewData();
}
void recvOneChar() {
if (Serial.available() > 0) {
receivedChar = Serial.read();
newData = true;
}
}
void showNewData() {
if (newData == true) {
Serial.print("This just in ... ");
Serial.println(receivedChar);
newData = false;
}
}