Recently i have started working on Arduino Nano, my code is below , i un able to transmit & get the data on "soft serial "
Does soft serial work for Arduino Nano? Please let me know friends
//************ #include <SoftwareSerial.h>
SoftwareSerial mySerial = SoftwareSerial(10, 11);
// D6, D7 on board
void setup()
{
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("Goodnight moon!"); // it is printing on Serial monitor teminal
mySerial.begin(9600);
}
void loop()
{
mySerial.write('H'); // soft sending
char read_char = mySerial.read(); // soft reading
if(read_char == 'H') // comparing soft read data
{
Serial.println("Soft Serial is Working"); // it has to print on soft terminal
}
delay(1000);
}
I'm confused by the comment. On the Nano board, what are the labels by the pins you are using for SoftwareSerial?
Regards
Ray
Dear Ray,
Pins (10,11) = PD6, PD7 (of MCU) = D6,D7 (Marked on Nano board).
when i short / join them (D6,D7) , Code should print "Soft Serial is Working" on Serial Monitor.
Let me know whats wrong in my process.
when i short / join them D6, D7 ( MCU pins 10,11 ), Code should print "Soft Serial is Working" on Serial Monitor.
but its not. i observed read char is getting the value (-1).
void loop()
{
mySerial.print('H'); // Soft serial print
Serial.print(mySerial.read());// Hard serial print after reading soft serial byte, here its printing "-1"
Serial.print('A'); //Hard serial print "A"
mySerial.print('H'); // soft serial print
char read_char = mySerial.read();// pushing into variable after soft reading
delay(1000); // wait for 1 second
if(read_char == 'H') // if soft serial read byte = H
{
Serial.println("Soft Serial is Working"); // hard serail prints
}
}
As PaulS asked, how do you want to use SoftwareSerial in practice? What is the Nano talking to? I assume the loop test was just to try out SoftwareSerial?
As PaulS asked, how do you want to use SoftwareSerial in practice? What is the Nano talking to? I assume the loop test was just to try out SoftwareSerial?
Regards
Ray
Thanks friends for your support....
I planned to use hard serial for for machine (which has UART) & soft serial for printer.