# HC12 not working

**URL:** <https://forum.arduino.cc/t/hc12-not-working/943833>\
**Category:** Home Automation\
**Created:** [January 6, 2022, 12:41pm UTC](https://forum.arduino.cc/t/hc12-not-working/943833 "2022-01-06T12:41:28Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [January 8, 2022, 3:29pm UTC](https://forum.arduino.cc/t/hc12-not-working/943833/21 "2022-01-08T15:29:11Z")

</div>

**1.** Build the following connection diagram (Fig-1) between HC12 and UNO for both Sender (UNO-1) and Receiver (UNO-2). ( The diagram is taken from a working experiment).

 ![hc12-3](https://europe1.discourse-cdn.com/arduino/original/4X/f/9/7/f9723e3109569db89b3ede08a3fbd35429f61251.png)  
Figure-1:

**2.** Upload the following sketch in UNO-1 (Sender).

```cpp
#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 has arrived
  {
    char x = Serial.read(); //read the charcater
    SUART.print(x); //send the charcater to NANO-2
  }
}

```

**3.** Upload the following sketch in UNO-2 (Receiver)

```cpp
#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(13, OUTPUT); //DPin-13 works as output line
  digitalWrite(13, LOW); //built-in Led-L is OFF
}

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(13, HIGH); //L has arrived; turn ON Led-L
    }
    if (x == 'R')
    {
      digitalWrite(13, LOW); //R has arrived; turn OFF Led-L
    }
  }
}

```

**4.** Open Serial Monitor at UNO-1 with "No line ending" option for "Line ending tab" (Fig-2).

 ![SerialMonitorX](https://europe1.discourse-cdn.com/arduino/original/4X/5/f/6/5f6fc8bacd2ed772a36526055ba7e06eb5311e69.png)  
Figure-2:

**5.** Enter L in the inputBox of the Serial Monitor and then click on the Send Button.  
**6.** Check that the built-in Led-L of UNO-2 (Receiver) has turned ON.  
**7.** Enter R in the inputBox of the Serial Monitor and then click on the Send Button.  
**8.** Check that the built-in Led-L of UNO-2 (Receiver) has turned OFF.  
**9.** If Step-5 to 8 work, then add codes with Sender/Receiver sketches to control Led-L of UNO-1 from UNO-2.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [July 7, 2022, 3:29pm UTC](https://forum.arduino.cc/t/hc12-not-working/943833/22 "2022-07-07T15:29:49Z")

</div>

Closed on July 7, 2022, 3:29pm UTC

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

[Previous page](https://forum.arduino.cc/t/hc12-not-working/943833.md?page=1)
