Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project See About the Installation & Troubleshooting category.
Please read How to get the best out of this forum and pay special attention to how to post code; next apply what you've 'learned' to the code in your opening post.
Sir could you please tell me that when I'm using the Serial1 than which pins would I use ??and is there any library to add Serial1 or it is predefined for Leonardo?
Arduino Leonardo is based on ATmega32u4 chip, which has built-in USB communication. That means pins 0 (Rx) and 1(Tx) become Serial1. It´s predefined for Leonardo, there´s no need to call any additional library or define the pins. Just connect BT module to these pins.
In your code, instead of calling BTSerial.write(), call Serial1.write() instead.
I want to communicate between Leonardo and uno using Bluetooth.the uno dosent have the Serial1 so how could I send value to the Leonardo if Leonardo has Serial1 but uno don't have...please help
You will need two BT modules then. One connected to Uno and another connected to Leonardo. You wil also need to write slightly different codes for each of them.
The code above is the transmitter. It uses SoftwareSerial, so it works on the Uno. The other code can use Serial1 of Leonardo, but it shall be written to receive the data that Uno is sending...
What is done in the loop of the example´s code is basically what you will need, but reading from Serial1 and comparing with the characters of your code ( 'r', 'b', 'f' and 'a').
the communication between Uno and the first Bluetooth module is done by SoftwareSerial, as in the code you´ve posted in #1. The Uno sends data through this Bluetooth module (let´s call it BT1);
the Bluetooth module 2 (BT2) will receive the data and pass to Leonardo through Serial1 (BT will be connected to RX/TX of Leonardo).