I can't seem to get either to function. I see some garbage coming out depending on what pins I use. Can anyone confirm it works?
Maybe you are using the wong pins
From the refernce page:
Not all pins on the Leonardo support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
I haven't even gotten to the point of worrying about the receive yet. I'm simply trying to print a string out of a sketch to a com port on my laptop. Nothing but gibberish.
I just did a test, I must admit I haven't tried using softwareserial on the Yun, but it worked as expected, no problems.
my test sketch below.
I used a USB/serial converter connected to pin 9 on the Yun
#include <SoftwareSerial.h>
SoftwareSerial mySerial(8, 9);
int x = 0;
void setup()
{
mySerial.begin(9600);
mySerial.println("Hello, world?");
}
void loop() // run over and over
{
mySerial.print("Loop");
mySerial.println(x);
x++;
delay(1000);
}
Thanks ERNI for taking the time to verify. Much appreciated. Something still isn't right though. With your sketch I still get odd characters. I'm using a serial card slot adapter on my laptop which I use all the time for various things with no problem. I even connect pin 8 to 9 and then sent the mySerial.read() out my Serial1 port and monitored that. Same result. I get in ASCII "u w U ENQ". Does the Arduino output standard RS-232 levels? Don't think pinmode matters? Doesn't seem to make any difference. Here's my code...
#include <SoftwareSerial.h>
SoftwareSerial mySerial(8, 9);
void setup()
{
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
mySerial.begin(9600);
Serial1.begin(9600); // Set the baud.
// Wait for U-boot to finish startup. Consume all bytes until we are done.
do {
while (Serial1.available() > 0) {
Serial1.read();
}
delay(1000);
} while (Serial1.available()>0);
Serial1.print("Serial Ready");
}
void loop() // run over and over
{
mySerial.print("TEST");
Serial1.write(mySerial.read());
delay(1000);
}
Does the Arduino output standard RS-232 levels?
No that would mean -13 to +13V, so if that is what you are using, it will damage your Yun.
Arduino use TTL level (0.5V).
One more thing standard RS-232 are inverted, which could explain why see garbled text.
https://www.sparkfun.com/tutorials/215
I use one of these cheap USB/Serial converters.
If you have an Arduino Uno you could use that instead
Ah ha. My ignorance exposed. That explains a lot. So your serial to usb automatically adjusts to the TTL levels? Thanks!