I am working on an application where it would be great to be able to have two Arduino Nanos talk to each other with as little delay as possible, as well as be able to read follow up transmissions quickly.
I am using an HC-12 wireless kit. I have been trying all sorts of different code and so far none has shown less than about 2 seconds latency between transmit and receive.
I have tried very basic code from tutorials and each is the same
Here is an example of one try,
Transmit:
int test = 1;
void setup() {
Serial.begin(1200);
}
void loop() {
char response[3] = "ML";
Serial.write(response);
delay(5000);
}
Receive
char test[3];
void setup() {
Serial.begin(1200);
pinMode(LED_BUILTIN, OUTPUT);
Serial.setTimeout(50);
}
void loop() {
if(Serial.available() > 0)
{
int test = Serial.read();
if(test == "ML") ;
{
digitalWrite(LED_BUILTIN, HIGH);
delay(5);
digitalWrite(LED_BUILTIN, LOW);
Serial.println("There");
}
}
}
I only need to transmit 3 numbers or letters, nothing crazy, help?