HC12 radio transmission problem (the receiver only receives -1)

Hello everyone

I use 2 HC12 and I try a radio transmission between a MEGA and a UNO (the MEGA isn’t an official arduino). I just try to send a potentiometer value but wathever I do te receiver receives -1 (even if a try to send a letter so the problem isn’t from the potentiometer). The good thing is that the receiver receive -1 only when the transmitter transmit something.

It’s a simple code but i put ithem below (receiver and transmitter).

Do somebody else has already seen the same problem?

I thought about the fact that the jumper wires are bad so can it be the problem?

transmitter:

#include <SoftwareSerial.h>
SoftwareSerial HC12(10, 11); // HC-12 TX Pin, HC-12 RX Pin
int pot = A1;
void setup() {
Serial.begin(9600);             // Serial port to computer
HC12.begin(9600);               // Serial port to HC12
pinMode(pot,INPUT);
}
void loop() {  
int val = map(analogRead(pot),0,1024,0,255);
HC12.write(val);      // Send that data to HC-12  
delay(1000);
}

receiver:

#include <SoftwareSerial.h>
SoftwareSerial HC12(10, 11); // HC-12 TX Pin, HC-12 RX Pin
int LED = 3;

void setup() {
Serial.begin(9600);             // Serial port to computer
HC12.begin(9600);               // Serial port to HC12
pinMode(LED,OUTPUT);
}
void loop() {
while (HC12.available()) {        // If HC-12 has data
  int val = HC12.read();
  Serial.println(HC12.read());      // Send the data to Serial monitor
  analogWrite(LED,val);
}
}

Thanks for your help!

Software serial's constructor takes RX, TX as parameters. Your comments suggest that you have them the wrong way round.

Since you're trying to send a value from 0-255, you might be better off sending a byte instead of an int.

Thank you, the probleme was on the receiver, so i modify his code and now it work as expected, i just put byte instead of int like that

byte val = HC12.read();