Arduino Serial Communication problems

 

I have been working on a cycle computer for a project and have a problem communicating via Serial data. I have tried the examples on the website and changed the baud rate and many things. Here are my current two programs to test whether the 2nd arduino is even recieving data. 

TRANSMITTING PROGRAM

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11);

void setup() {  

}

void loop() {

  mySerial.begin(9600); 

  mySerial.write(45);

  delay(10000);

}

RECEIVING PROGRAM

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11);

void setup() {

  mySerial.begin(9600);

}

void loop() {

  if (mySerial.available()) {

    Serial.print("Hello");

  }

}

I did both of these programs without the Software Serial data library also and it didn't work either.

I also tryed many other variations of this program

thanks for help  

How are the 2

How are the 2 Arduinos connected . I would suggest to connect pin 10 with pin 11 and vice versa and a common GND connection between the Arduino boards.

 

Edit: mySerial.begin(9600) should be placed in the setup function, not the loop function

They are only connected via

They are only connected via pins 10 and 11 with 11 attached to the 10 on the other arduino. There is no common ground.

Thanks

Share your grounds

Yup, you’re gunna need that gnd connection between the boards. Everyone, everywhere, shares grounds. Connect 'em all.

I attached the grounds but
I attached the grounds but it still didn’t work so I increased the BAUD rate to 115200, and that worked.
Thanks for your help