I'm attempting to connect two Arduino boards to eachother using SotwareSerial as the title suggests!
The two boards are 1) Arduino UNO and 2)MultiWii Controller (MWC) FLIP 1.5 (Uses ATMega328 chip).
The idea, is to get Serial TX on the "MWC" FLIP 1.5 to Serial RX on the UNO.
These are my connections thus far:
MWC Pin ------->UNO Pin
Digital 3 (TX)--->Digital 6 (RX)
Digital 9 (RX)--->Digital 9 (TX)
This is the code on the MWC Chip -- the TX chip. (NOTE: These functions are called to run in a header file)
#include "attout.h"
#include "SoftwareSerial.h"
SoftwareSerial altSerial(9,3); // RX=9 TX=3
void startaltserial(){
altSerial.begin(9600);
}
void attout(){
pinMode(3,HIGH);
pinMode(9,HIGH);
altSerial.print('1');
}
NOTE: I also tried altSerial.write('1')
. Same result (or lack of one).
Then, the RX Code on the UNO Board:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(6,9); // RX=6 TX=9
void setup()
{
// Open serial communications:
Serial.begin(9600);
// Set the data rate for the SoftwareSerial port
mySerial.begin(9600);
}
void loop()
{
while (mySerial.available()>0) {
Serial.println(mySerial.read());
}
}
When I open Serial Monitor for the UNO board, I get nothing but zeroes streaming down. Curiously, if I disconnect the TX OUT wire from MWC, the Serial stream stops!
This means, as far as I can tell, that the UNO is doing its job of receiving, and the MWC is doing it's job of transmitting, but something is wrong with the formatting inbetween, so that I end up with zeroes.
Additionally, if I change the baud rate, the Serial Monitor output changes. When I go to 1200 baud, I get nothing but '4' followed quickly by '1' and then carriage return, so it looks like '41'.
Hope we can find a solution to these quandaries. My next course of action is trying I2C, but I'm not sure about it yet...
pinMode(3,HIGH);
doing? Pinmode accepts INPUT or OUTPUT, not HIGH. Also this line isn't needed.