tx rx help plz

i have been using the nrf 24 transevers but needed more range so purchased the transmitter receaver pair from seeedstudios. i only could find this set of codes wich works but im unsure how to intergrate it i want to push a button on tx side and have the rx side do something like move forward or backward. im confused with the multi pin output as the nrf didnt have this any help would be apreciated…this is the example code i found tx first

void setup()
{
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  Serial.begin(9600);
}
void loop()
{
  unsigned char i=0;
  for(i=0;i<16;i++)
  {
    send_data(i);
    Serial.print("i=");
    Serial.println(i,DEC);
    delay(500);
    send_data(0);
    delay(500);
  }
}
//====================================
void send_data(unsigned char data)
{
  digitalWrite(4,(data&0x01));
  digitalWrite(5,(data&0x02));
  digitalWrite(6,(data&0x04));
  digitalWrite(7,(data&0x08));
}
int data=0;

void setup()
{
  pinMode(3,INPUT);
  pinMode(4,INPUT);
  pinMode(5,INPUT);
  pinMode(6,INPUT);
  pinMode(7,INPUT);
  attachInterrupt(1,RF_VT,RISING);
  Serial.begin(9600);
}
void loop()
{
}
//=======================================
void RF_VT() // interrupt service function
{
  data=(digitalRead(4)<<3)+(digitalRead(5)<<2)+(digitalRead(6)<<1)+(digitalRead(7)<<0);
  Serial.print("data=");
  Serial.println(data,DEC);
}

Please post link to the transmit/receive pair you're using.

yes i ment to sorry here it is http://www.seeedstudio.com/depot/2KM-Long-Range-RF-link-kits-w-encoder-and-decoder-p-321.html

Serial.print("data="); Serial.println(data,DEC);

You don't Serial.print inside of an ISR

See: http://www.gammon.com.au/interrupts

.

Thank you Larry I'll look over this info that is how it was worded in the only example code I could find but I'll update when I can

merkzilla: Thank you Larry I'll look over this info that is how it was worded in the only example code I could find but I'll update when I can

You need to set a flag in the ISR to indicate that new data has arrived. On every pass through loop, check for new data, do something with the new data, and clear the flag.

this code seems to work do i have to make a seperate "for" for every button though?

int SW1 = 8; //forward
int SW2 = 9; //backward
int SW3 = 3; //left
int SW4 = 2; //right
//int SW5 = ; //lights

void setup()
{
  pinMode(SW1, INPUT_PULLUP);
  pinMode(SW2, INPUT_PULLUP);
  pinMode(SW3, INPUT_PULLUP);
  pinMode(SW4, INPUT_PULLUP);
  
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  Serial.begin(9600);
}
void loop(void)
{
  unsigned char i=0;
  //backward
  for ( digitalRead(SW1) == HIGH;i=1;)
  {
    
    send_data(i);
    Serial.print("i=");
    Serial.println(i,DEC);
    delay(500);
    send_data(0);
    delay(500);
    
  }
}
//====================================
void send_data(unsigned char data)
{
  digitalWrite(4,(data&0x01));
  digitalWrite(5,(data&0x02));
  digitalWrite(6,(data&0x04));
  digitalWrite(7,(data&0x08));
}
  for ( digitalRead(SW1) == HIGH;i=1;)

The initialization clause doesn't initialize anything. The while clause doesn't compare anything. There is no increment clause.

Why are you abusing a for statement this way?