Simple comms with HC12 and Nano

Hello, Ineed some guidance please sourcing a sketch, or ideas.
I am building a fishing alarm and need to send a simple "L" or "R" from one HC12/Nano to another about 6m away. The second HC12/Nano will then decode the message and flash the appropriate alarm to say if the left or right bite alarm has been triggered. The bite alarm outputs an audio signal of about 1v peak to peak.
Any suggestions please as to where I might find a similar project or sketch.
Many thanks, stay safe.

What have you tried so far ?

Read the voltage with an Analog pin, when it reaches 1V (Or a different threshold if needed), set an OUTPUT LOW, use 2 wires to connect the sender to the receiver, in the receiver, set a pin input pull-up, and when the voltage drops, do whatever you want. If the digital read does not get enough of a bias, use analog read on an analog pin.

Or send a value with the HC12 (Didn't read the post properly)

Thanks for your responses.
I have looked at loads of existing sketches but they all seem to transmit strings of data, which confuses the issue for me, and only one set of data. I need to choose between two inputs and then trigger one of two alarms at the receiver. I will carry on searching the net for possible sketches i can modify. As i am very new to this is not easy!
Thanks again

Send 'A' or 'B'
Check if received char is 'A' - do one thing, or 'B' - do another.

I will carry on searching the net for possible sketches i can modify.

It is unlikely that you will find a sketch that does what you want

Is your aim to do this project and never to use the Arduino again or to learn to use the Arduino for this and future projects ?

If the former than find a pair of transmit and receive sketches that transmit and receive "strings of data" and reduce the strings to a single character and come back when that works. If the latter then start by looking at and trying the examples in the IDE so that you learn the basics. Using two HC12's is actually the same as connecting the 2 Nanos with a Serial link except that the message is passed by radio. Maybe get a Serial link working first then introduce the HC12s

Thank you. My intention is to try and learn to use Arduino, i have loads of ideas i would like to try. My struggle is learning C++ , my thoughts being to look at an existing sketch and figure how it worked, then modify as you suggested. I did similar with PIC Basic years ago and it worked well.
Thanks for your help, i will do as you suggest and look for something similar and modify the code.
Stay safe

1. Connect HC12-1 with NANO-TX and HC12-2 with NANO-RX as per following diagram of Fig-1. Also, connect LEDL and LEDR with NANO-RX.
Hc12-2xy.png
Figure-1:

2. You send L from the InputBox of Serial Monitor (Fig-2) of NANO-TX to NANO-RX and observe that LEDL of NANO-RX comes ON. LEDR remains OFF. Choose "No line ending" option for the "Line ending tab" of Serial Monitor.


Figure-2:

3. You send R from the InputBox of Serial Monitor (Fig-2) of NANO-TX to NANO-RX and observe that LEDR of NANO-RX comes ON. LEDL remains OFF. Choose "No line ending" option for the "Line ending tab" of Serial Monitor.

4. Upload the following sketches in NANO-TX and NANO-RX.
(1) Sketch for NANO-TX

#include<SoftwareSerial.h>
SoftwareSerial SUART(10, 11);  //SRX = DPin-10, STX = DPin-11

void setup() 
{
  Serial.begin(9600);
  SUART.begin(9600);  //activate Software Serial Port (SUART)
}

void loop() 
{
  byte y = Serial.available();//check if a charcater has come from Serial Monitor
  if(y != 0)  //a charcater hhas arrived
  {
    char x = Serial.read(); //read the charcater
    SUART.print(x); //send the charcater to NANO-2
  }
}

(2) Sketch for NANO-TX

#include<SoftwareSerial.h>
SoftwareSerial SUART(10, 11);  //SRX = DPin-10, STX = DPin-11

void setup()
{
  Serial.begin(9600);
  SUART.begin(9600);  //activate Software Serial Port (SUART)
  pinMode(7, OUTPUT); //DPin-7 works as output line
  pinMode(8, OUTPUT);
}

void loop()
{
  byte y = SUART.available();//check if a charcater has come from NANO-1 via SUART Port
  if (y != 0) //a charcater has arrived
  {
    char x = SUART.read(); //read the charcater
    if (x == 'L')
    {
      digitalWrite(7, HIGH); //L has arrived; ignite LEDL
      digitalWrite(8, LOW); //LEDR is OFF
    }
    if (x == 'R')
    {
      digitalWrite(7, LOW); //R has arrived; ignite LEDR
      digitalWrite(8, HIGH); //LEDR is ON
    }
  }
}

5. Press RESET buttons on both NANOs.
6. Bring in Serial Monitor of NANO-TX.
7. Follow Step-2 and 3.

Hc12-2xy.png

Thank you so much for your information, it is invaluable for me to use to start this project off, and is exactly what I was looking for. I am very much a novice with Arduino having only just started in the last couple of weeks.
I really do appreciate your time and input with this, thank you again.
Stay well and stay safe
Kindest regards

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.