1
votes

I want to set the brightness of a LED of my arduino. I know how to do this with the analogwrite() function of the arduino. Now I want to do this without the analogwrite() function and use PORT manipulations.

I can write to a port like this: PORTD = 0b00001000. This sets an output to PIN 3. But with this I cant set the brightness. Is there some trick to set the brightness for this?

1
Probably offtopic, since it's an electronic problem. Belongs on electronics.stackexchange.comjp-jee
It is pure programming on a arduino, nothing to do with electronics. You can assume that the electronics I've made are correct.P Griep

1 Answers

1
votes

Once your Pin is set logically HIGH, it will serve the specified voltage (probably 5V) and the current that is needed (limited by the board). Thus, you do not have any influence on these ouptput parameters.

You might consider switching the LED on and off with a sufficiently high frequency, so that it appears to be dimmed (Pulse-width modulation).