Arduino Nano and CC1101

Hello everyone,
i like to put 2 leds on this sketch ... one when it receives and one when transmit ... can anyone help me ?

#include <ELECHOUSE_CC1101_SRC_DRV.h>
#include <RCSwitch.h>

int pinRx; // int for Receive pin.
int pinTx; // int for Transmit pin.

RCSwitch mySwitch = RCSwitch();

int buttonPin;                 // for button pin.
int buttonState = 0;          // button state
int ccSetRx = 0;             // reset state for Receive
int long value = 5393;      // int to save value
int bits = 24;             // int to save bit number
int prot = 1;             // int to save Protocol number
int puls = 320;          // int to save pulse length

void setup() {
  Serial.begin(9600);

pinRx = 0; pinTx = 6;  // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.
buttonPin = 4;  // set button on pin D4.


  if (ELECHOUSE_cc1101.getCC1101()){       // Check the CC1101 Spi connection.
  Serial.println("Connection OK");
  }else{
  Serial.println("Connection Error");
  }

//CC1101 Settings:                (Settings with "//" are optional!)
  ELECHOUSE_cc1101.Init();            // must be set to initialize the cc1101!
//ELECHOUSE_cc1101.setRxBW(812.50);  // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.
//ELECHOUSE_cc1101.setPA(10);       // set TxPower. The following settings are possible depending on the frequency band.  (-30  -20  -15  -10  -6    0    5    7    10   11   12)   Default is max!
  ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.

  pinMode(buttonPin, INPUT);     // set pin4 as input

}
void loop() {

   buttonState = digitalRead(buttonPin);  // read digital pin and save the state to int


   if (buttonState == HIGH) {         // the button is pressed. Set transmit on.

  ccSetRx = 0;                       // set resetstate to 0 for next reinit to Recive
  ELECHOUSE_cc1101.SetTx();         // set Transmit on
  mySwitch.disableReceive();       // Receiver off
  mySwitch.enableTransmit(pinTx); // Transmit on

  mySwitch.setProtocol(prot);    // send Received Protocol
  mySwitch.setPulseLength(puls);// send Received Delay
  mySwitch.send(value, bits);  // send Received value/bits

    Serial.print("Transmit ");
    Serial.print( value );
    Serial.print(" / ");
    Serial.print( bits );
    Serial.print("bit ");
    Serial.print("Protocol: ");
    Serial.print( prot );
    Serial.print(" Delay: ");   
    Serial.println( puls );     
   }

   
  if (buttonState == LOW && ccSetRx == 0){  //the button is not pressed. set cc1101 to Receive.
   
  ELECHOUSE_cc1101.SetRx();         // set Receive on
  mySwitch.disableTransmit();      // set Transmit off
  mySwitch.enableReceive(pinRx);  // Receiver on
  ccSetRx = 1;
   }

  if (buttonState == LOW && ccSetRx == 1) {   //the button is not pressed and set receive is finish. Receive values.



  if (mySwitch.available()){
   
    Serial.print("Received ");
    Serial.print( mySwitch.getReceivedValue() );
    Serial.print(" / ");
    Serial.print( mySwitch.getReceivedBitlength() );
    Serial.print("bit ");
    Serial.print("Protocol: ");
    Serial.print( mySwitch.getReceivedProtocol() );
    Serial.print(" Delay: ");   
    Serial.println( mySwitch.getReceivedDelay() );

    value =  mySwitch.getReceivedValue();        // save received Value
    bits = mySwitch.getReceivedBitlength();     // save received Bitlength
    prot = mySwitch.getReceivedProtocol();     // save received Protocol
    puls =  mySwitch.getReceivedDelay();      // save received pulse length
   
    mySwitch.resetAvailable();
   
   }
   }

}

Please edit your post to add code tags, and explain the problems you are having.

Posting instructions are given in the "How to get the best out of the forum" post.

This would be a good place to put

  digitalWrite(TransmitLEDPin, HIGH);
  digitalWrite(ReceiveLEDPin, LOW);

This would be a good place to put

  digitalWrite(TransmitLEDPin, LOW);
  digitalWrite(ReceiveLEDPin, HIGH);

Sorry my excusses ... this is the first time i used this forum.
Please forgive me.

Thank you John for your time to answer my question.
I am just a beginner so excuse me if i ask dumb questions.
So if i understand it gooed it must be like this

 ELECHOUSE_cc1101.SetTx(); // set Transmit on
  mySwitch.disableReceive(); // Receiver off
  mySwitch.enableTransmit(pinTx); // Transmit on
digitalWrite(TransmitLEDPin, HIGH);
  digitalWrite(ReceiveLEDPin, LOW);

and

ELECHOUSE_cc1101.SetRx(); // set Receive on
  mySwitch.disableTransmit(); // set Transmit off
  mySwitch.enableReceive(pinRx); // Receiver on
digitalWrite(TransmitLEDPin, LOW);
  digitalWrite(ReceiveLEDPin, HIGH);

i understand that i must put a 220ohm resistor to the led.
but on witch pin must i put the leds ?

On any digital I/O pins you are not using for other things. It looks like you are already using Pins 2, 4, and 6.

Thank you very much sir for your help.
So i only have to change the script in how you explain en put 1 led on pin 3 and ground and the other one on pin 5 and ground.

Pins 3 and 5 should work. Remember the current limiting resistors. Also remember that LED's have a + side and a - side. If they don't work at first, turn them round.

During the time it took you to post that reply, you could have fixed your post, as requested. That would have been far better.

Your post #1 is still not fixed and is breaking forum rules....

Thank u very much sir it works like a charm !!!
Respect that you took the time to help me :slight_smile: