Hello Guys,
I have used this forum a ton and learned so much from it, but this is my first post so please forgive if I do it wrong! Here's my problem:
I have 2 hc-12 modules, one connected to a UNO and another connected to a mega. Both are running identical sketches to simply send messages back and forth and print to serial monitor.
When I send a message from the mega the uno outputs it to serial monitor perfectly. When the message is sent from uno to mega... nothing happens.
I have spent hours trying different things, but always the same.
Any ideas?
Also, I have pin 2 connected to TX on HC-12 and pin 3 connected to RX on HC-12
Here is the code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); //RX, TX
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
}
void loop() {
if(Serial.available() > 0){//Read from serial monitor and send over HC-12
String input = Serial.readString();
mySerial.println(input);
}
if(mySerial.available() > 1){//Read from HC-12 and send to serial monitor
String input = mySerial.readString();
Serial.println(input);
}
delay(20);
}