pulse width modulation

analogWrite(pin num,255)//100% duty cycle so it completely on
analogWrite(pin num,125)/50% dutycycle so its 50% of time on and 50 percent of time off)

my question is in the above image whatever may be the duty cycle it on (5v) and off(nearly o v)

then how do we getting half of that voltage i mean around 2.5 from the actual 5v(change in value between 0 to 255 only says on time of time )

.thank you in advance

how do we getting half of that voltage i mean around 2.5

Use a potential divider.

I'm not sure what you want to know.

Perhaps you are asking how a 50% duty cycle results in 2.5volts when the actual voltage is either 5volts or 0volts?

The answer is that whatever is using the current averages it. For example the average current through a resistor will be half what it would be if the voltage was constant at 5 volts. If the current is used to light an LED it will be on for half the time and off for half the time and your eye will average the light and see a dim LED.

...R