HOW to visually represent PWM ??

hey fellas how would i go about, being there is a way, to represent the average value of voltage being outputted by a pwm pin ; but not the wave like this

because i do not have an oscilloscope , i just want to send the value out through serial ;
so if i have something like analogWrite 35 i would send out something like 2.45 volts ... or even easier is there a formula that i could just implement to figure out the average voltage.
Thanks.

Look at your figures. The duty cycle is what is specified in a call to analogWrite(). This translates into a percentage on/off in a given time. The "average" voltage is then (duty cycle/255) * Vcc.

Not everything that is connected to a PWM pin sees the on/off cycle as an average voltage that is continuous from 0 to 100% of Vcc.

Have you seen this:-
http://www.thebox.myzen.co.uk/Tutorial/PWM.html
It has an animated PWM diagram and a bit of an explanation about filters that turn this pulse train into a DC level.

The "average" voltage is then (duty cycle/255) * Vcc.

thanks for that one paul

and thanks mr gumpy i will take a look at that
...

so could one create lets say a small 5v variable power supply using the arduino., of course along with all the right components and pulse width modulation ?
it might not be the best practical way to do it , when you could use something with no code like a potentiometer , but it would work i might have to read grumpy's power tutorials for that one huh

could one create lets say a small 5v variable power supply using the arduino

You are going to have to be more specific that that. What voltage variation do you want, what current must it supply, what is your input voltage?

it would be using just the arduino pwm pin to pwm from 0 - 5 , assuming i would not exceed the pins max current ratings..

well actually i think i am wrong, because if use an arduino pwm pin and try to use it as a variable power supply on something with a max rating of 1 volt , i will damage it because with pwm i am never really giving it a variable voltage , just pulses of 5v? correct

well actually i think i am wrong, because if use an arduino pwm pin and try to use it as a variable power supply on something with a max rating of 1 volt , i will damage it because with pwm i am never really giving it a variable voltage , just pulses of 5v? correct

Yes, and no. The Arduino does output 5 volt pulses, but a suitable filter consisting of just some resistors and capacitors can produce a steady n volt output, where n ranges from 0 to 5.

If you had read that page I sent you the link to you would not need to ask that question.

assuming i would not exceed the pins max current ratings.

Well as the maximum current rating is under 40mA you are not going to power much.