problems with hc-12 , and controlling it with software serial

Im trying to build transceivers that can send messages back and forth. i got the arduino to have its own software keyboard that can be used to type messages to the serial monitor and I got the device to be able to read messages it receives. now my one problem is interfacing this with both software serial and a hc-12 for ranged text communication between arduino (arduino's, arduiness?) my code is a bit long but im sure someone will try it out (also has pong on it)

(msg code marks the spot i am sending messages)
my problem has been that the arduino doesnt seem to recive the hc-12's messages (even when using the hc-12 messenger example.)

you will need
5 buttons
1 arduino 12C oled
1 arduino (im using Leonardo)
1 hc-12

pin 10 connects to hc-12 tx(or maybe vise versa)
pin 9 connects to hc012 rx (or maybe vise versa)

pin 4 is right button (move up)
pin 8 is left button (move down)
pin 7 is the left middle button (back)
pin 5 is the right middle button (select/enter)
pin 6 is the middle button (send message)

at any time you can press and hold left and right to go to the main menu.

thank you to anyone willing to help.
i make videos on all my projects if someone helps me WILL mention them in the video by user name or name of selection.

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>


#include <SoftwareSerial.h>


#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

SoftwareSerial mySerial(10, 9);
int x=0;
int xs=0;
int l=0;
int r=0;
int lm=0;
int rm=0;
int bt=0;
int lin=0;
int lib=0;
int bou=8;
int bouc=0;
int pm=0;
int ot=0;
int ok=0;
int px=0;
char newlet = 65;
int pbx=0;
int pby=0;
int cpux=0;
int pboy=0;
int pbox=0;
char odlet =0;


int msub=0;
int menu=0;
String msg = "no new messages";


String smsg = "";
void setup() {
 
 mySerial.begin(9600);
 
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize with the I2C addr 0x3C (128x64)
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
pinMode(8,INPUT_PULLUP);
pinMode(7,INPUT_PULLUP);
pinMode(6,INPUT_PULLUP);
pinMode(5,INPUT_PULLUP);
pinMode(4,INPUT_PULLUP);

}





void loop() {
 if (digitalRead(4)==0) {r=r+1;}
 else {r=0;}
 
if (digitalRead(8)==0) {l=l+1;}
 else {l=0;}

 if (digitalRead(7)==0) {lm=lm+1;}
 else {lm=0;}

if (digitalRead(5)==0) {rm=rm+1;}
 else {rm=0;}

 if (digitalRead(6)==0) {bt=bt+1;}
 else {bt=0;}



  if (mySerial.available() > 0) {
    // read the incoming byte:
   msg = mySerial.readString();
mySerial.println(msg);
   msg.toUpperCase();
  }


if (r>50) { if (l>50){menu=0;msub=0;px=0;}}


if (menu==0) {












 if (msub==0) {
   display.setTextSize(1);
  if (r==1) {x=x+8;}
  if (l==1) {x=x-8;}



  if (x>16) {x=0;}
 if (x<0) {x=16;}
   display.clearDisplay();




   
  if (lib==1) {lin=lin-10;}
  if (lib==0) {lin=lin+10;}
  display.drawLine(lin,31,lin+15,31,WHITE);
  display.drawLine(lin,30,lin+15,30,WHITE);
 if (lin>128) {lib=1;}
 if (lin<-10) {lib=0;}
display.drawRoundRect(32,2, 94,24,3,WHITE);
display.setCursor(34,3);

display.print(msg);

display.setCursor(34,18);


if (analogRead(1)>500) {
  display.print("CHARGING AT ");
  display.print(analogRead(1)*(5.0 / 1023.0));
 
}




 display.setCursor(0,0);
  display.print("TEXT");
display.setCursor(0,8);
display.print("GAME");
display.setCursor(0,16);
display.print("BEAM");
display.setCursor(0,23);
display.print(analogRead(0)*(3.7 / 1023.0));

  if (x==0) {

  if (rm==1) {
    delay(500);
rm=2;
      rm=0;
    msub=2;
  
  }}



  if (x==8) {

  if (rm==1) {
    rm=0;
   msub=1;
  }}



   if (x==16) {

  if (rm==1) {
    rm=0;
  } }


  
   display.setCursor(24,x);
   display.print("<");


   display.display();
}





if (msub==1) {// games menu games menu games menu games menu games menu games menu


  
  if (r==1) {x=x+8;}
  if (l==1) {x=x-8;}


  if (x>16) {x=0;}
 if (x<0) {x=16;}

display.clearDisplay();

 display.setCursor(0,0);
  display.print("PONG");
display.setCursor(0,8);
display.print("FIGHT");
display.setCursor(0,16);
display.print("<back");









 if (x==0) {

  if (rm==1) {
  msub=3;
  rm=0;
  }}



  if (x==8) {

  if (rm==1) {
     
  }}



  if (x==16) {

  if (rm==1) {
    rm=0;
  msub=0;
     
  }}



   display.setCursor(32,x);
   display.print("<");

display.display();
  
}

if (msub==2) {
 display.clearDisplay();
  display.drawRoundRect(-3,0, 128,32,3,WHITE);

  //msg code----------------------------------------------------------------------------------------------------


if (ot==0){

 if (l>10) {newlet=newlet-1;} 
if (r>10) {newlet=newlet+1;}
 
}

if (smsg=="") {
display.setCursor(4,2);
display.print(msg);



if (rm==1) {smsg=smsg+' ';}


 



  display.setCursor(4,24);
  display.drawRoundRect(-3,23, 128,9,3,WHITE);
  display.print(smsg);
  



   if (ok>10) {
display.print(" < ENTER TO TYPE");}
else {display.print("_< ENTER TO TYPE");}
  
  


  
}

else { 
  display.setCursor(0,1); 
   display.print(smsg);
   if (ok>10) {
display.print(" <");}
else {display.print("_<");}

   display.setCursor(62,18); // main!!!!!!!
  display.print(newlet);

  
 

  
 display.setCursor(62,26);
  display.print("^");




 
 if (rm==1) {odlet=newlet; smsg=smsg+newlet;}
  if (lm==1) {smsg.remove(smsg.length()-1,1);}

  if (bt==1) {msg=smsg;mySerial.println(smsg); smsg=""; } 
  
  if (newlet>90) {newlet=32;}
  if (newlet<32) {newlet=90;}
  
if (r==1) {newlet=newlet+1;}
  if (l==1) {newlet=newlet-1;}
  
  }



  display.display();


  if (ot<4) {ot=ot+1;}
  else {ot=0;}


  if (ok<25) {ok=ok+1;}
  else {ok=0;}
}





if (msub==3){// PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG PONG!
 
  
  display.clearDisplay();

if (pm==0){
  
 display.setTextSize(2);
 display.setCursor(42,bou);
    display.print("PONG");
    if(bouc==0){bou=bou+1;}
    if(bouc==1){bou=bou-1;}
    if (bou>18){bouc=1;}
    if (bou<0){bouc=0;}


display.setTextSize(1);
display.setCursor(16,16);
display.print("1P");

display.setCursor(104,16);
display.print("2P");

if (l==1){
pm=1; 
 
}

}

if (pm==1)
   {

if (l>1){
 px=px-1;
  
}
if (r>1){
  px=px+1;
}

if (l>5){
 px=px-1;
  
}
if (r>5){
  px=px+1;
}


if (px<0){
  px=0;
}


if (px>25){
  px=25;
}



if (cpux<0){
  cpux=0;
}


if (cpux>25){
  cpux=25;
}





    display.drawPixel(pbx,pby, WHITE);




    
display.drawLine(125,cpux,125,cpux+6,WHITE);
    
     display.drawLine(0,px,0,px+6,WHITE);

if (pby>cpux) {cpux=cpux+1;}
if (pby<cpux+3) {cpux=cpux-1;}


     
     if (ot>0) {
  if (pboy==0){pby=pby+1;}
    if (pbox==0){pbx=pbx+1;}
    
 if (pboy==1){pby=pby-1;}
    if (pbox==1){pbx=pbx-1;}


    if (pbx>124){pbox=1;}

    
   if (pbx<1){pbox=0;
   
   
   if (pby<px-1) {pm=0;}
   if (pby>px+7) {pm=0;}
   }

if (pby>30){pboy=1;}
   if (pby<1){pboy=0;}

   
   }
   }


    
display.display();

 if (ot<4) {ot=ot+1;}
  else {ot=0;}

  
}









}

}

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read.

Please remove unnecessary blank lines from your code before posting to the forum. One or two to separate code into sections is fine but large spaces for no reason just make for more scrolling when we're trying to read your code.

brenden_nerd_:
pin 10 connects to hc-12 tx(or maybe vise versa)
pin 9 connects to hc012 rx (or maybe vise versa)

Well, which is it?

brenden_nerd_:
the arduino doesnt seem to recive the hc-12's messages (even when using the hc-12 messenger example.)

Post a link to where you got this example from.

thanks for the reply pert. i got the example code from a "Instructable" its the same code as in the software serial example on this website.

Sorry for not being clear my problem is that the hc-12 inst replying to AT commands when i send them. such as when i say "AT" I expect to get back the message "OK" but i get nothing.

here is link

You didn't answer either of my questions.

I answered one but i gave the link of the wrong tab somehow?dont know. How just search "software serial" and look at the arduino example. Also rx connects to tx, tx connects to rx. (The first rx/tx is arduino 2nd is hc-12. )

As far as the blank lines its for organization it makes it easier to see the district difference between menu A and menu B. Considering all the sub menus my code has alot of them. Like reading a novel without chapters.

Why? a simple comment, // with a blank line
or
// blank line
// begin new code block
// blank line
Would be much simpler..

Doc

Docedison:
Why? a simple comment, // with a blank line
or
// blank line
// begin new code block
// blank line
Would be much simpler..

Doc

Its just how i organize my code. Organization is a personal thing and people do it in a way that is best for me. If i use a simple single line comment then ill scroll right past it when going to fix the code. And ill spend an exstra 3 minutes trying to find a simple //blah blah code. With multiple spaces i notice it because its this big eye sore in my code.