I built two scetch for testing. One for Arduino Nano no1 and another for Arduino Nano no2. They are tested and working, not only written to this page.
No2 is sending "hello" and No1 is listening and sending it to PC via Serial. The speed (1200bps) is slow, but so it is easier to see what is happening.
Connect Pin10 of no1 to Pin11 of no2 and gnd to gnd. Connect the Nanos to the USB-ports of the PC and set a monitor program (1200, 8N1) to listen no1.
This seems to be a good way to test Serial.print, Serial.println and Serial.write commands. You will be surprised.
/*No1:/
#include <SoftwareSerial.h> SoftwareSerial mySerial(10, 11); // RX, TX void setup() { Serial.begin(1200); Serial.println("Testing"); mySerial.begin(1200); } void loop() { // run over and over if (mySerial.available()) //If this is missing, you get fast repeating carpage { Serial.write(mySerial.read()); Serial.print("."); } }
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
Serial.begin(1200);
Serial.println("Testing");
mySerial.begin(1200);
}
void loop() { // run over and over
if (mySerial.available()) //If this is missing, you get fast repeating carpage
{
Serial.write(mySerial.read());
Serial.print(".");
}
}
/*No2:/
#include <SoftwareSerial.h> SoftwareSerial mySerial(10, 11); // RX, TX void setup(){ mySerial.begin(1200); } void loop(){ mySerial.print("Hello"); }
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup(){
mySerial.begin(1200);
}
void loop(){
mySerial.print("Hello");
}