Hello guys
I am designing the circuit using the Arduino Leonardo.
In this time, I am wondering how much current is returned when I write in the code like 'analogWrite(pin, 255);' ?
I heard that the maximum output current of one pin is 50mA. So I guess the current returned is also 50mA. Am I right!?
Or is the type of output a voltage?
It would be very thankful to your reply!
analogWrite(pin, 255);
This will output Vcc or 5VDC
The outputs can safely supply 20ma to the load.
analogWrite sends a PWM waveform out on a PWM pin.
analogWrite(pin, 0); sends 0VDC
analogWrite(pin, 255); sends 5VDC
analogWrite(pin, 127); sends 50% Duty Cycle
Look up PWM
So I guess the current returned is also 50mA. Am I right!?
No.
The current drawn, not returned, is dependant on the load resistance. The peak output voltage is always 5V, irrespective of what PWM value you use other than zero.
So use ohms law to determin what the peak current will be. Anything over 40mA will damage your Arduino pin according to the data sheet. Anything over 20mA and you will not get the full output voltage either.
While the peak current is always the same the PWM value will affect the avrage current which in turn can affect the brightness of LEDs or he speed of D.C. motors.
See http://www.thebox.myzen.co.uk/Tutorial/PWM.html