Arduino RFM12B to Arduino RFM12B

Hi to all that take the time to read this.

The set up = (One Arduino with RFM12B transceiver) To (One Arduino with RFM12B transceiver).

What I am trying to do is = The first two program’s that I have posted down below work great. (TX and RX)
They have A switch on pin (const int buttonPin = 5), that when pushed down will make the led on RX side light up
(const int ledPin = 9) .

What I need help on is = I want to get ride of the switch pin input (const int buttonPin = 5), and I want to
make the Arduino (TX) make the led go on and off, on and off, on and off, and so on.
I have the program, but it’s not working so great. (No Switch pin 5, just in the code. (TX). ).

TX

int val;
int new_val;
int power1;
int buttonState = 0;
const int buttonPin = 5;

#include <RFM12B.h>


#define NODEID        2  
#define NETWORKID    99  
#define GATEWAYID     1  
#define SERIAL_BAUD  115200
char input = 0;
int interPacketDelay = 1000;
uint8_t KEY[] = "ABCDABCDABCDABCD";

typedef struct  { int power1, power2; } PayloadTX;
PayloadTX emontx; 
 
RFM12B radio;


void setup()
{
  Serial.begin(SERIAL_BAUD);
  radio.Initialize(NODEID, RF12_433MHZ, NETWORKID);
  radio.Encrypt(KEY);
  Serial.println("Transmitting...\n\n");
  int button1 = 5;
}

void loop()
{
  val = analogRead(5);
  new_val = map(val, 0, 1023, 253, 0); 
  buttonState = digitalRead(buttonPin);
  emontx.power1=emontx.power1=new_val;
  emontx.power2=emontx.power2=buttonState;

  if (Serial.available() > 0) {
    input = Serial.read();
    if (input >= 48 && input <= 57) 
    {
      interPacketDelay = 100 * (input-48);
      if (interPacketDelay == 0) interPacketDelay = 1000;
      Serial.print("\nChanging delay to ");
      Serial.print(interPacketDelay);
      Serial.println("ms\n");
    }
  }
  radio.Wakeup();
  radio.Send(GATEWAYID, &emontx, sizeof emontx);
  
 
  Serial.print("power1: "); Serial.println(emontx.power1); 
  Serial.print("power2: "); Serial.println(emontx.power2); 
 
delay(100);
  
}

RX

int led1 = 9;
 byte power1;
 const int ledPin =  9;
 const int MyData_NodeID=10;

 #include <RFM12B.h>

 #define NODEID           1  
 #define NETWORKID       99  
 #define SERIAL_BAUD 115200
 uint8_t KEY[] = "ABCDABCDABCDABCD";

 RFM12B radio;

 typedef struct {int power1, power2;} 
 PayloadTX; 
 PayloadTX emontx;  

void setup()
 {
  radio.Initialize(NODEID, RF12_433MHZ, NETWORKID);
  radio.Encrypt(KEY);     
  Serial.begin(SERIAL_BAUD);
  Serial.println("Listening...");
  pinMode (led1, OUTPUT);
 }

 void loop()
 {
  if (radio.ReceiveComplete())
  {
    if (radio.CRCPass())
    {

      emontx=*(PayloadTX*) radio.Data; 
      Serial.print("power1: "); 
      Serial.println(emontx.power1); 
      Serial.print("power2: "); 
      Serial.println(emontx.power2); 
      
     if (emontx.power2 == HIGH) {     
        // turn LED on:    
        digitalWrite(ledPin, HIGH);  
      } 
      else {
        // turn LED off:
        digitalWrite(ledPin, LOW); 
        delay(100);

      }
    }
  }
}

No Switch pin 5, just in the code on off on off. (TX).

int val;
int new_val;
int power1;
//int buttonState = 0;
//const int buttonPin = 5;
byte hi;
#include <RFM12B.h>


#define NODEID        2  
#define NETWORKID    99  
#define GATEWAYID     1  
#define SERIAL_BAUD  115200
char input = 0;
int interPacketDelay = 1000;
uint8_t KEY[] = "ABCDABCDABCDABCD";

typedef struct  { int power1, power2; } PayloadTX;
PayloadTX emontx; 
 
RFM12B radio;


void setup()
{
  Serial.begin(SERIAL_BAUD);
  radio.Initialize(NODEID, RF12_433MHZ, NETWORKID);
  radio.Encrypt(KEY);
  Serial.println("Transmitting...\n\n");
  //int button1 = 5;
}

void loop()
{
  val = analogRead(5);
  new_val = map(val, 0, 1023, 253, 0);
  
delay(1000);
 hi = 1;
 delay(1000);
 hi = 0;
  
 
  emontx.power1=emontx.power1=new_val;
  emontx.power2=emontx.power2=hi;

  if (Serial.available() > 0) {
    input = Serial.read();
    if (input >= 48 && input <= 57) 
    {
      interPacketDelay = 100 * (input-48);
      if (interPacketDelay == 0) interPacketDelay = 1000;
      Serial.print("\nChanging delay to ");
      Serial.print(interPacketDelay);
      Serial.println("ms\n");
    }
  }
  radio.Wakeup();
  radio.Send(GATEWAYID, &emontx, sizeof emontx);
  
 
  Serial.print("power1: "); Serial.println(emontx.power1); 
  Serial.print("power2: "); Serial.println(emontx.power2); 
 
delay(100);
  
}

No Switch pin 5, just in the code on off on off. (RX).

 byte power1;
 const int ledPin =  9;
 const int MyData_NodeID=10;

 #include <RFM12B.h>

 #define NODEID           1  
 #define NETWORKID       99  
 #define SERIAL_BAUD 115200
 uint8_t KEY[] = "ABCDABCDABCDABCD";

 RFM12B radio;

 typedef struct {int power1, power2;} 
 PayloadTX; 
 PayloadTX emontx;  

void setup()
 {
  radio.Initialize(NODEID, RF12_433MHZ, NETWORKID);
  radio.Encrypt(KEY);     
  Serial.begin(SERIAL_BAUD);
  Serial.println("Listening...");
  pinMode (led1, OUTPUT);
 }

 void loop()
 {
  if (radio.ReceiveComplete())
  {
    if (radio.CRCPass())
    {

      emontx=*(PayloadTX*) radio.Data; 
      Serial.print("power1: "); 
      Serial.println(emontx.power1); 
      Serial.print("power2: "); 
      Serial.println(emontx.power2); 
      
     if (emontx.power2 == HIGH) {     
        // turn LED on:    
        digitalWrite(ledPin, HIGH);  
      } 
      else {
        // turn LED off:
        digitalWrite(ledPin, LOW); 
        delay(100);

      }
    }
  }
}

I will have to re think this, I think I have it.......Thank for all that took the time to read it......

HI
Any idea why this is not working for arduino 101