Problem with RF links, 1 element of the data array is being received other not !

hello guys,
i am building a robot which can self navigate or being controlled from a controller which i built too,
so the radio communication is made via RF links 315 MHZ these ones :http://www.ekt2.com/products/productdetails?ProductId=751d1eff-dc9a-4234-be84-a71188ef11c6

so the problem is i am sending 3 values, the value of the forward potentiometer, the steering potentiometer and third value is a boolean 0 or 1 which indicate if the robot is in reverse state or forward state, so the first too value for forward and steering are not being received by the receiver but the third value is being received when i click the reverse push button, i receive 0 or 1, I am trying to figure out what the problem is but so far i wasn’t lucky so any help please ?

and thanks in advance :slight_smile:

these are the codes :

the Transmitter controller

/* Project Robot Controller Transmitter */
#include <VirtualWire.h>

char ArrayController[12]; //controlling transmitter initially 12

int throttlePotPin = A0;
int steeringPotPin = A1;

//These values will be sent by the transmitter
int valThrottle = 0;  
int valSteering = 0;
int valReverse = 0;

int ControlTransmitterPin = 5; //transmitter pin

//Shift register of the forward backward LEDs
int latchPin1 = 9;
int clockPin1 = 10;
int dataPin1 = 8;
int forwardBackwardLeds = 0;

//Shift register of the Steering LEDs
int latchPin2 = 12;
int clockPin2 = 13;
int dataPin2 = 11;
int SteeringLeds = 0;

//Shift register of the 7 segment display
int latchPin3 = A3; //A3 17
int clockPin3 = A4; //A4 18
int dataPin3 = A2; //A2 16
int displayLeds = 0;


int lightPatternButton = 2; //Reverse Push Button switch
int reverseButton = 3;//Reverse Push Button switch
int selfNavigateButton = 4; //Reverse Push Button switch

//Green LED autopilote on, red LED autopilote off
int greenLED = 6;
int redLED = 7;

//Number of Patterns
int patternNumber = 0;
boolean lastPattern = LOW;
boolean currentPattern = LOW;

//Self Navigate State
int selfNavigateState = 1;
boolean lastNav = LOW;
boolean currentNav = LOW;

void setup()
{
  //Transmitter setup
  vw_setup(2000); // Bits per sec
  vw_set_tx_pin(ControlTransmitterPin); //RF sending pin 
  
  pinMode(latchPin1, OUTPUT);
  pinMode(dataPin1, OUTPUT);
  pinMode(clockPin1, OUTPUT);
  
  pinMode(latchPin2, OUTPUT);
  pinMode(dataPin2, OUTPUT);
  pinMode(clockPin2, OUTPUT);
  
  pinMode(latchPin3, OUTPUT);
  pinMode(dataPin3, OUTPUT);
  pinMode(clockPin3, OUTPUT);
  

  
  pinMode(lightPatternButton, INPUT_PULLUP);
  pinMode(reverseButton, INPUT_PULLUP);
  pinMode(selfNavigateButton, INPUT_PULLUP);
  
  pinMode(greenLED, OUTPUT);
  pinMode(redLED, OUTPUT);
  
  Serial.begin(9600);
}


boolean patterndebounce(boolean last, int button)
{
  boolean current = digitalRead(button);
  if(last != current)
  {
    delay(5);
    current = digitalRead(button);
  }
  return current;
}

void loop()
{  
   int reverseButtonState = digitalRead(reverseButton); //Reverse Button digitalRead
   
    //changing the number of light pattern
    currentPattern = patterndebounce(lastPattern, lightPatternButton);
    if(lastPattern != currentPattern)
    {
      patternNumber++;
    
    }
    lastPattern = currentPattern;
    
    if(patternNumber > 9){
      patternNumber = 0;
    }
   
    //Serial.print(patternNumber);
    //Serial.print('\n');
    
    //Self Navigate State On or Off
    currentNav = patterndebounce(lastNav, selfNavigateButton);
    if(lastNav != currentNav)
    {
       selfNavigateState++;
    
    }
    lastNav = currentNav;
    
    if(selfNavigateState > 1){
      selfNavigateState = 0;
    }
    
    if(selfNavigateState == 0){
      digitalWrite(greenLED, LOW);
      digitalWrite(redLED, HIGH);
    
   
  
     //If statement for the forward backward LEDs
     if(reverseButtonState == LOW){ //Move backward
       valReverse = 1;
       
       int readingFB = analogRead(throttlePotPin);
       readingFB = map(readingFB, 0, 1023, 1023, 0); 
       readingFB = constrain(readingFB, 800, 1023);
       //Serial.print(readingFB);
       //Serial.print('\n');
       
       if(readingFB >= 0 && readingFB <= 820){
         forwardBackwardLeds = B00000000;
       }else if(readingFB > 820 && readingFB <= 850){
         forwardBackwardLeds = B00001000;
       }else if(readingFB > 850 && readingFB <= 900){
         forwardBackwardLeds = B00001100;
       }else if(readingFB > 950 && readingFB <= 990){
         forwardBackwardLeds = B00001110;
       }else if(readingFB > 990 && readingFB <= 1023){
         forwardBackwardLeds = B00001111;
       }
       
       
       updateShiftRegisterFB();
        
    }else if(reverseButtonState == HIGH){ //Move forward
       valReverse = 0;
       
       int readingFB = analogRead(throttlePotPin);
       readingFB = map(readingFB, 0, 1023, 1023, 0); 
       //Serial.print(readingFB);
       //Serial.print('\n');
       
       if(readingFB >= 0 && readingFB <= 881){
         forwardBackwardLeds = B00000000;
       }else if(readingFB > 881 && readingFB <= 910){
         forwardBackwardLeds = B00010000;
       }else if(readingFB > 910 && readingFB <= 950){
         forwardBackwardLeds = B00110000;
       }else if(readingFB > 950 && readingFB <= 990){
         forwardBackwardLeds = B01110000;
       }else if(readingFB > 990 && readingFB <= 1023){
         forwardBackwardLeds = B11110000;
       }
       updateShiftRegisterFB();
    }
    
     int readingSteering = analogRead(steeringPotPin);
     readingSteering = constrain(readingSteering, 0, 700); 
     //Serial.print(readingSteering);
     //Serial.print('\n');
     
     
     if(readingSteering >= 400 && readingSteering <= 500){  
       SteeringLeds = B00000000;
     }else if(readingSteering > 500 && readingSteering <= 580){
       SteeringLeds = B00001000;
     }else if(readingSteering > 580 && readingSteering <=620 ){
       SteeringLeds = B00011000;
     }else if(readingSteering > 620 && readingSteering <= 700){
       SteeringLeds = B00111000;
     }else if(readingSteering < 400  && readingSteering >= 300 ){
       SteeringLeds = B00000100;
     }else if(readingSteering < 300  && readingSteering >= 200 ){
       SteeringLeds = B00000110;
     }else if(readingSteering < 200  && readingSteering >= 0 ){
       SteeringLeds = B00000111;
     }
     
     updateShiftRegisterSteering();
   
   }else if(selfNavigateState == 1){
      digitalWrite(redLED, LOW);
      digitalWrite(greenLED, HIGH);
   }
  
   //Display 
   if(patternNumber == 0){
     displayLeds = B11101110;  
   }else if(patternNumber == 1){
     displayLeds = B00101000;
   }else if(patternNumber == 2){
     displayLeds = B11001101;
   }else if(patternNumber == 3){
     displayLeds = B01101101;
   }else if(patternNumber == 4){
     displayLeds = B00101011;
   }else if(patternNumber == 5){
     displayLeds = B01100111;
   }else if(patternNumber == 6){
     displayLeds = B11100111;
   }else if(patternNumber == 7){
     displayLeds = B00101100;
   }else if(patternNumber == 8){
     displayLeds = B11101111;
   }else if(patternNumber == 9){
     displayLeds = B01101111;
   }
   
   updateShiftRegisterDisplay();
   
   //Sending lines
   sprintf(ArrayController, "%d,%d,%d.",valThrottle,valSteering, valReverse);
   vw_send((uint8_t*)ArrayController, strlen(ArrayController));
   vw_wait_tx(); 
   //Serial.println(Array);
   

  
}//end of loop()

void updateShiftRegisterFB() //Forward Backward LEDs
{
  digitalWrite(latchPin1, LOW);
  shiftOut(dataPin1, clockPin1, LSBFIRST, forwardBackwardLeds);
  digitalWrite(latchPin1, HIGH);
}

void updateShiftRegisterSteering() //Steering LEDs
{
  digitalWrite(latchPin2, LOW);
  shiftOut(dataPin2, clockPin2, LSBFIRST, SteeringLeds);
  digitalWrite(latchPin2, HIGH);
}

void updateShiftRegisterDisplay() //7segment LED
{
  digitalWrite(latchPin3, LOW);
  shiftOut(dataPin3, clockPin3, LSBFIRST, displayLeds);
  digitalWrite(latchPin3, HIGH);
}

and the receiver codes on the robot side are in the first comment

receiver codes on robot side

/* Robot sketch */

#include <VirtualWire.h> //the RF library

int controllingReceiver = 3; // receiving pin

//Right motor
int enablePin1 = 5;
int in1Pin1 = A4; // digital pin controller of right motor
int in2Pin1 = A5; // digital pin controller of right motor

  //Left motor
  int enablePin2 = 6;
  int in1Pin2 = 9; // digital pin controller of right motor
  int in2Pin2 = 10; // digital pin controller of right motor


void setup()
{
  pinMode(in1Pin1, OUTPUT);
  pinMode(in2Pin1, OUTPUT);
  pinMode(enablePin1, OUTPUT);
  
  pinMode(in1Pin2, OUTPUT);
  pinMode(in2Pin2, OUTPUT);
  pinMode(enablePin2, OUTPUT);
  
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  
  Serial.begin(9600);
  
  //Receiving setup
  vw_setup(2000); // Bits per sec
  vw_set_rx_pin(controllingReceiver);
  vw_rx_start();       // Start the receiver PLL running
}

void loop()
{
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  
  if (vw_get_message(buf, &buflen)) // Non-blocking
  {
    int valThrottle = atoi(strtok((char*)buf, ","));  // Look for a comma, the return the data before it.
    int valSteering = atoi(strtok(NULL, ",")); // same as above
    boolean valReverse =  atoi(strtok(NULL, ".")); 
    
    Serial.print(valThrottle);
    Serial.print('\n');
    Serial.print(valSteering);
    Serial.print('\n');
    Serial.print(valReverse);
    Serial.print('\n');
    
    if(valReverse == 0){ // go forward this is the reverse of the controller here 1 means reverse is off
      if(valThrottle >= 0 && valThrottle <= 881){
        valThrottle = 0;
        analogWrite(enablePin1, valThrottle);   
      
      }else if(valThrottle > 881 && valThrottle <= 1023){
        valThrottle = valThrottle / 4; //this makes the range from 0 - 1023 to 0 - 255 or we can use function map(analogRead(pin), 0, 1023, 255, 0) to remap the pot value 
        setMotorRight(valThrottle, valReverse);
        
      }  
     }
    
  }
  
}

void setMotorRight(int speed, boolean reverse)
{
  analogWrite(enablePin1, speed); //the speed of the motor given by this pin
  digitalWrite(in1Pin1, !reverse);
  digitalWrite(in2Pin1, reverse);
}

Some debugging ideas.

First, is the data all correctly in place for the sending?

//Sending lines
   sprintf(ArrayController, "%d,%d,%d.",valThrottle,valSteering, valReverse);
   vw_send((uint8_t*)ArrayController, strlen(ArrayController));
   vw_wait_tx(); 
   //Serial.println(Array);

The debug Serial.println should be on the valThrottle, valSteering, and valReverse, or the sprintf buffer ArrayController. Serial.prinln(Array)makes no sense.

If you indeed have the three integers as you expect, I would suggest that you send and receive them as an integer array, instead of going through char string conversion with sprintf and the parsing with strtok and atoi. It will help to test that section of code.

You will define an integer array TSRData[3] with the three elements valThrottle, valSteering, and valReverse.
Then

vw_send((uint8_t*) & TSRData, sizeof(TSRData));

On the receive side you declare a similar array for TSRData.

if (vw_get_message(buf, &buflen)) // Non-blocking
{
 memcpy (& TSRData, buf, buflen);}

TSRData should have the three values with out going through the parsing and conversions. The uint8_t* takes care of breaking the data into bytes on the sending end, and memcpy sets it up to be put back together.
Using the cast on the send and memcpy on the receive is useful for float arrays, and structures as well.

thanks a lot for the help, i will try it

the thing is that i had these codes since last year which was working fine but i forgot how to make it work, but i was all this afternoon till now trying to understand the meaning of every function from cplusplus.com, so i got something and before try it i saw your reply, well i like your method way more so hope everything will work

but what do you think was going wrong in my codes ?

for this //Serial.println(Array); it's commented because no need for it, it's from the codes of my old project

i changed the codes but nothing still, i tried to print on the monitor the values from the array but i get nothing

this is the TX :

/* Project Robot Controller Transmitter */
#include <VirtualWire.h>

//char ArrayController[12]; //controlling transmitter initially 12
int ArrayController[3];

int throttlePotPin = A0;
int steeringPotPin = A1;

//These values will be sent by the transmitter
int valThrottle = 0;  
int valSteering = 0;
int valReverse = 0;

int ControlTransmitterPin = 5; //transmitter pin

//Shift register of the forward backward LEDs
int latchPin1 = 9;
int clockPin1 = 10;
int dataPin1 = 8;
int forwardBackwardLeds = 0;

//Shift register of the Steering LEDs
int latchPin2 = 12;
int clockPin2 = 13;
int dataPin2 = 11;
int SteeringLeds = 0;

//Shift register of the 7 segment display
int latchPin3 = A3; //A3 17
int clockPin3 = A4; //A4 18
int dataPin3 = A2; //A2 16
int displayLeds = 0;


int lightPatternButton = 2; //Reverse Push Button switch
int reverseButton = 3;//Reverse Push Button switch
int selfNavigateButton = 4; //Reverse Push Button switch

//Green LED autopilote on, red LED autopilote off
int greenLED = 6;
int redLED = 7;

//Number of Patterns
int patternNumber = 0;
boolean lastPattern = LOW;
boolean currentPattern = LOW;

//Self Navigate State
int selfNavigateState = 1;
boolean lastNav = LOW;
boolean currentNav = LOW;

void setup()
{
  //Transmitter setup
  vw_set_tx_pin(ControlTransmitterPin); //RF sending pin 
  vw_setup(4000); // Bits per sec
  
  pinMode(latchPin1, OUTPUT);
  pinMode(dataPin1, OUTPUT);
  pinMode(clockPin1, OUTPUT);
  
  pinMode(latchPin2, OUTPUT);
  pinMode(dataPin2, OUTPUT);
  pinMode(clockPin2, OUTPUT);
  
  pinMode(latchPin3, OUTPUT);
  pinMode(dataPin3, OUTPUT);
  pinMode(clockPin3, OUTPUT);
  

  
  pinMode(lightPatternButton, INPUT_PULLUP);
  pinMode(reverseButton, INPUT_PULLUP);
  pinMode(selfNavigateButton, INPUT_PULLUP);
  
  pinMode(greenLED, OUTPUT);
  pinMode(redLED, OUTPUT);
  
  Serial.begin(9600);
}


boolean patterndebounce(boolean last, int button)
{
  boolean current = digitalRead(button);
  if(last != current)
  {
    delay(5);
    current = digitalRead(button);
  }
  return current;
}

void loop()
{  
   int reverseButtonState = digitalRead(reverseButton); //Reverse Button digitalRead
   
    //changing the number of light pattern
    currentPattern = patterndebounce(lastPattern, lightPatternButton);
    if(lastPattern != currentPattern)
    {
      patternNumber++;
    
    }
    lastPattern = currentPattern;
    
    if(patternNumber > 9){
      patternNumber = 0;
    }
   
    //Serial.print(patternNumber);
    //Serial.print('\n');
    
    //Self Navigate State On or Off
    currentNav = patterndebounce(lastNav, selfNavigateButton);
    if(lastNav != currentNav)
    {
       selfNavigateState++;
    
    }
    lastNav = currentNav;
    
    if(selfNavigateState > 1){
      selfNavigateState = 0;
    }
    
    if(selfNavigateState == 0){
      digitalWrite(greenLED, LOW);
      digitalWrite(redLED, HIGH);
    
   
  
     //If statement for the forward backward LEDs
     if(reverseButtonState == LOW){ //Move backward
       valReverse = 1;
       
       int readingFB = analogRead(throttlePotPin);
       readingFB = map(readingFB, 0, 1023, 1023, 0); 
       readingFB = constrain(readingFB, 800, 1023);
       //Serial.print(readingFB);
       //Serial.print('\n');
       
       if(readingFB >= 0 && readingFB <= 820){
         forwardBackwardLeds = B00000000;
       }else if(readingFB > 820 && readingFB <= 850){
         forwardBackwardLeds = B00001000;
       }else if(readingFB > 850 && readingFB <= 900){
         forwardBackwardLeds = B00001100;
       }else if(readingFB > 950 && readingFB <= 990){
         forwardBackwardLeds = B00001110;
       }else if(readingFB > 990 && readingFB <= 1023){
         forwardBackwardLeds = B00001111;
       }
       
       
       updateShiftRegisterFB();
        
    }else if(reverseButtonState == HIGH){ //Move forward
       valReverse = 0;
       
       int readingFB = analogRead(throttlePotPin);
       readingFB = map(readingFB, 0, 1023, 1023, 0); 
       //Serial.print(readingFB);
       //Serial.print('\n');
       
       if(readingFB >= 0 && readingFB <= 881){
         forwardBackwardLeds = B00000000;
       }else if(readingFB > 881 && readingFB <= 910){
         forwardBackwardLeds = B00010000;
       }else if(readingFB > 910 && readingFB <= 950){
         forwardBackwardLeds = B00110000;
       }else if(readingFB > 950 && readingFB <= 990){
         forwardBackwardLeds = B01110000;
       }else if(readingFB > 990 && readingFB <= 1023){
         forwardBackwardLeds = B11110000;
       }
       updateShiftRegisterFB();
    }
    
     int readingSteering = analogRead(steeringPotPin);
     readingSteering = constrain(readingSteering, 0, 700); 
     //Serial.print(readingSteering);
     //Serial.print('\n');
     
     
     if(readingSteering >= 400 && readingSteering <= 500){  
       SteeringLeds = B00000000;
     }else if(readingSteering > 500 && readingSteering <= 580){
       SteeringLeds = B00001000;
     }else if(readingSteering > 580 && readingSteering <=620 ){
       SteeringLeds = B00011000;
     }else if(readingSteering > 620 && readingSteering <= 700){
       SteeringLeds = B00111000;
     }else if(readingSteering < 400  && readingSteering >= 300 ){
       SteeringLeds = B00000100;
     }else if(readingSteering < 300  && readingSteering >= 200 ){
       SteeringLeds = B00000110;
     }else if(readingSteering < 200  && readingSteering >= 0 ){
       SteeringLeds = B00000111;
     }
     
     updateShiftRegisterSteering();
   
   }else if(selfNavigateState == 1){
      digitalWrite(redLED, LOW);
      digitalWrite(greenLED, HIGH);
   }
  
   //Display 
   if(patternNumber == 0){
     displayLeds = B11101110;  
   }else if(patternNumber == 1){
     displayLeds = B00101000;
   }else if(patternNumber == 2){
     displayLeds = B11001101;
   }else if(patternNumber == 3){
     displayLeds = B01101101;
   }else if(patternNumber == 4){
     displayLeds = B00101011;
   }else if(patternNumber == 5){
     displayLeds = B01100111;
   }else if(patternNumber == 6){
     displayLeds = B11100111;
   }else if(patternNumber == 7){
     displayLeds = B00101100;
   }else if(patternNumber == 8){
     displayLeds = B11101111;
   }else if(patternNumber == 9){
     displayLeds = B01101111;
   }
   
   updateShiftRegisterDisplay();
   
   //Sending lines
   ArrayController[valThrottle,valSteering, valReverse];
   vw_send((uint8_t*) & ArrayController, sizeof(ArrayController));
   vw_wait_tx(); 
   
   //here we say store the arguments with this format %d,%d,%d. into ArrayController
   /*sprintf(ArrayController, "%d,%d,%d.",valThrottle,valSteering, valReverse); //%d to say it's an integer and not decimal, %ls for pointer, %x for hexadecimal
   vw_send((uint8_t*)ArrayController, strlen(ArrayController));
   vw_wait_tx(); */
   //Serial.println(Array);
   

  
}//end of loop()

and this is the RX:

/* Robot sketch */

#include <VirtualWire.h> //the RF library

int receivingArray[3];

int controllingReceiver = 3; // receiving pin

//Right motor
int enablePin1 = 5;
int in1Pin1 = A4; // digital pin controller of right motor
int in2Pin1 = A5; // digital pin controller of right motor

 //Left motor
 int enablePin2 = 6;
 int in1Pin2 = 9; // digital pin controller of right motor
 int in2Pin2 = 10; // digital pin controller of right motor


void setup()
{
 pinMode(in1Pin1, OUTPUT);
 pinMode(in2Pin1, OUTPUT);
 pinMode(enablePin1, OUTPUT);
 
 pinMode(in1Pin2, OUTPUT);
 pinMode(in2Pin2, OUTPUT);
 pinMode(enablePin2, OUTPUT);
 
 pinMode(13, OUTPUT);
 digitalWrite(13, LOW);
 
 Serial.begin(9600);
 
 //Receiving setup
 vw_setup(4000); // Bits per sec
 vw_set_rx_pin(controllingReceiver);
 vw_rx_start();       // Start the receiver PLL running
}

void loop()
{
 uint8_t buflen = VW_MAX_MESSAGE_LEN;
 uint8_t buf[buflen];
 
 if (vw_get_message(buf, &buflen)) // Non-blocking
 {
   int valThrottle;
   int valSteering;
   int valReverse;
   
   receivingArray[valThrottle,valSteering,valReverse];
   memcpy (& receivingArray, buf, buflen);
   
   /*int valThrottle = atoi(strtok((char*)buf, ","));  // Look for a comma, the return the data before it.
   int valSteering = atoi(strtok(NULL, ",")); // same as above
   boolean valReverse =  atoi(strtok(NULL, ".")); */
   
   Serial.print(receivingArray[valReverse]);
   Serial.print('\n');
   Serial.print(valSteering);
   Serial.print('\n');
   Serial.print(valReverse);
   Serial.print('\n');
   
   if(valReverse == 0){ // go forward this is the reverse of the controller here 1 means reverse is off
     if(valThrottle >= 0 && valThrottle <= 881){
       valThrottle = 0;
       analogWrite(enablePin1, valThrottle);  
     
     }else if(valThrottle > 881 && valThrottle <= 1023){
       valThrottle = valThrottle / 4; //this makes the range from 0 - 1023 to 0 - 255 or we can use function map(analogRead(pin), 0, 1023, 255, 0) to remap the pot value
       setMotorRight(valThrottle, valReverse);
       
     }  
    }
   
 }
 
}

void setMotorRight(int speed, boolean reverse)
{
 analogWrite(enablePin1, speed); //the speed of the motor given by this pin
 digitalWrite(in1Pin1, !reverse);
 digitalWrite(in2Pin1, reverse);
}

I still do not see the debug serial prints on the TX sketch. You absolutely need to confirm that the data is there to be sent. I do not think that you are populating ArrayController properly. Try

// ArrayController[valThrottle,valSteering, valReverse];
   ArrayController[0] = valThrottle;
   ArrayController[1] = valSteering;
   ArrayController[2] = valReverse;
for(int i=0;i<3;i++){
   Serial.println(ArrayController[i]);}//debug print out

Once you confirm the data on the sending end. I would configure the receiving code to similar structure.
Declare variables globally like in the TX sketch.

int receivingArray[3];
int valThrottle = 0;  
int valSteering = 0;
int valReverse = 0;
if (vw_get_message(buf, &buflen)) // Non-blocking
 {
   memcpy (& receivingArray, buf, buflen);
   valThrottle = receivingArray[0];
   valSteering = receivingArray[1];
   valReverse = receivingArray[2];

   for(int i=0;i<3;i++){
   Serial.println(receivingArray[i]);}//debug print out
}

If this doesn’t work, we’ll need to debug the radio operation, and get the sketch to pure software by connection the RX and TX pins with jumper wires.

ok i changed to this :

ArrayController[0] = valThrottle;
   ArrayController[1] = valSteering;
   ArrayController[2] = valReverse;
   for(int i=0;i<3;i++){
     Serial.println(ArrayController[i]);
   }//debug print out
   
   vw_send((uint8_t*) & ArrayController, sizeof(ArrayController));
   vw_wait_tx();

but what i got on the monitor for TX is the same results as on the receiver it’s this :

0
0
0 or 1 when i click the reverse pushbutton

but the throttle pot is working because the LEDs are changing when i turn the pot

After i changed the codes like you said on both sides, the TX led on arduino for transmitter is going crazy now and same for receiver the TX LED is going crazy !

shouldn't the RX on receiving arduino go crazy ?!

i added a digitalWrite(13, HIGH) if the valReverse == 1 and LOW if the valReverse == 0 on the Receiver side and this worked fine when i click the reverse pushbutton on the transmitter side

I find no place in the code where you assign values to valThrottle and valSteering except for the initial 0. I do see the reverse button and valReverse getting set.

You need to get the transmission on a timer or when the data changes so that it is not sending data every time through the loop. TX led on the receiver is probably due to the serial debug on the receive.

cattledog:
I find no place in the code where you assign values to valThrottle and valSteering except for the initial 0. I do see the reverse button and valReverse getting set.

You need to get the transmission on a timer or when the data changes so that it is not sending data every time through the loop. TX led on the receiver is probably due to the serial debug on the receive.

exactly ! i just found it ! :smiley: everything works fine now !

many thanks for all the help and the new method you gave me :smiley:

how do i send data when the data changes ? :S

one more question:
what about if i need to send more data, i mean in the array i need to send like 5 elements values
so all i have to do is to change the number of elements in the array ?

int array [5] instead of int array[3] ?

Good job getting it sorted out. You can check if the problem was always the assignment or if there was a problem in the strtok/atoi code. I prefer the cast and memcpy method.

so all i have to do is to change the number of elements in the array ?
int array [5] instead of int array[3] ?

Yes. that's correct.

how do i send data when the data changes ? :S

if data != old data ---send it---old data=data

thanks a lot :smiley:
the other method works fine but i prefer yours it's way less complicated and more flexible many thanks :slight_smile:

cattledog:
if data != old data ---send it---old data=data

by data you mean the array ?
about this can you please give me a small example :-[ from my code but small let's say about valThrottle