I am planning to change the brightness of an LED using a PIC 16F877A. I get suggestions that the brightness can be changed by changing the time interval between two pulses. But the brightness of the LED depends on its power, and that depends only on voltage and current (which we can't change in the PIC controller). Please explain how this works, or if the suggestion is wrong please suggest some other ideas.
Look up something called pulse width modulation, usually abbreviated PWM.
With PWM, you always switch the LED either full on or full off. However, you do this so fast that a human looking at the LED only perceives the average brightness.
It only takes a few 10s of Hz to get to the point where you can't see the individual pulses when looking directly at the LED. However, it will still flicker noticeably when you move your eyes. It is usually good to use a few 100 Hz minimum PWM frequency for brightness-adjusting LEDs. You can also soften the on/off transitions with added electrical components like capacitors and inductor.
The 16F877 has PWM generators built in. Take a look at the CCP modules. Once a CCP module is set up, all the firmware has to do is write a new duty cycle into the right register or registers to set the brightness.
By changing how the relative duration of turning the led on and off (own), you change its brightness perceive by human eyes.