help with code rf transmission 433mhz

hey all, i am trying to establish communication between two arduinos nanos with 433mhz transmitter and receiver.
i connected the transmitter to pin 12 and on the other nano the receiver to leg 11.

what i am trying to do is to send integer from the transmitter and to recevie it on the receiver.

trasmitter:

#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile

RH_ASK driver;

void setup()
{
         Serial.begin(9600);   // Debugging only
         if (!driver.init())
         Serial.println("init failed");
    Serial.begin(9600);  // Debugging only

    pinMode(A0,INPUT);
}

int vx;
void loop()
{
     vx = analogRead(A0);
       Serial.print(vx);
       Serial.print("  ");
       if(vx <550 && vx>480)               \\ the reading from the joystick when not been touched
       {
         int msg = 0 ;
      Serial.print("value is:");
      Serial.print(msg);
      Serial.print('\n');

       Serial.write(val);
       Serial.print('\n');
       driver.send(( uint8_t *) &msg, 1);
        delay(500);
        
       }

receiver:

#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile
#define data_res 11
RH_ASK driver;

void setup()
{
         Serial.begin(9600);   // Debugging only
         if (!driver.init())
         Serial.println("init failed");
   
    
    
}
void loop() {
   int received_value = 0;
  uint8_t buflen = 1;

   if (driver.recv((uint8_t *) &received_value, &buflen)) 
  {
      Serial.print("Received: ");
      Serial.println(received_value);
      delay(500);
  }
      
}

You didn't say what the result or problem is...

the problem is i that i get nothing on the receiver side.. the integet that i am trying to send is 0, i am trying to check out the value that the recevier is picking up (supposably 0)

With RF, there can be so many reasons for a lack of communication. You have to approach it step by step. Step 1 - did you try running the RF library example sketches?

Your receive buffer is too small for your declared size, one byte won't hold an int. But, the receiver code corrects that because if it receives 2 bytes, it sets buflen to 2. However, in your transmit code, you only send one byte. That is only half your message.

"Step 1 - did you try running the RF library example sketches?"

checked out the modules there are working fine with example code.

i tried to change the number of bytes from 1 to 2, still there is nothing.

Please post your updated sketches. We can't guess exactly what you did.

Never mind, I managed to solve the problem, thnx anyway!

shadowar:
Never mind, I managed to solve the problem, thnx anyway!

Please post your solution anyway, in case it might help people who encounter this thread in future and have a similar problem.

I have made alredy some progress so i am putting here the final code. The code is for controling a DC motor with a joystick using 433mhz RF and a module motor L298.

transmitter:

void setup()
{
         Serial.begin(9600);   // Debugging only
         if (!driver.init())
         Serial.println("init failed");
    Serial.begin(9600);  // Debugging only

    pinMode(A0,INPUT);
}

int vx;
void loop()
{
     vx = analogRead(A0);
       //Serial.print(vx);
       //Serial.print("  ");
      // delay(1000);
       if(vx <370 && vx>440)
       {
         int msg = 0 ;
      Serial.print("value is:");
      Serial.print(msg);
      Serial.print('\n');
       int val = 0 ;
       Serial.print(val);
       Serial.print('\n');
       driver.send(( uint8_t *) &val, 2);
        delay(20);
        
       }
      
       else if(vx > 550)
       {
        int msg = 1 ;
       Serial.print("value is:");
       Serial.print(msg);
       Serial.print('\n');
       int val = 1 ;
       Serial.print(val);
       Serial.print('\n');
       driver.send(( uint8_t *) &val, 2);
       delay(20);
       
       }
              else if(vx <200)
       {
        int msg = 2 ;
       Serial.print("value is:");
       Serial.print(msg);
       Serial.print('\n');
       int val = 2 ;
       Serial.print(val);
       Serial.print('\n');
       driver.send(( uint8_t *) &val, 2);
        delay(20);
       }
      
   
   
}

reciver:

#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile
#define data_res 11
#define ena 6
#define in3 3
#define in4 5
RH_ASK driver;

void setup()
{
         Serial.begin(9600);   // Debugging only
         if (!driver.init())
         Serial.println("init failed");
         
    
    
}
void loop() {
   int received_value = 0;
  uint8_t buflen = 2;

   if (driver.recv((uint8_t *) &received_value , &buflen)) 
  {
      if(received_value == 0)
      {
        Serial.print("stay");
        Serial.print('\n');
        delay(150);
      }
     // Serial.print("Received: ");
      //Serial.println(received_value);
      //delay(500);
      if(received_value == 1)
      {

        Serial.print("forword");
        Serial.print('\n');
    digitalWrite(ena,HIGH);
    digitalWrite(in3,LOW);
    digitalWrite(in4,HIGH);
        delay(150);
    digitalWrite(in4,LOW);
        
      }
      else if(received_value == 2)
      {
      Serial.print("backword");
      Serial.print('\n');
      digitalWrite(ena,HIGH);
      digitalWrite(in3,HIGH);
      digitalWrite(in4,LOW);
      delay(150);
      digitalWrite(in3,LOW);
      }
  }