Log in

View Full Version : PWM on a 16f628a



BlackNoir
- 4th January 2006, 15:09
Would anyone happen to have a little sample code that does PWM on a 16f628a? I'm new to the PWM concept so I'm trying to find something to get me started.

Thanks,
BlackNoir

Melanie
- 4th January 2006, 15:46
Have you seen the HPWM and PWM commands in the PBP manual? examples included theirin.

BlackNoir
- 4th January 2006, 16:37
Actually, I think I found something. I believe this will work:

Duty VAR BYTE
Freq VAR Word
LED VAR PortB.3

' changing the value for "Duty" will change the brightness
Duty=127 ' about 50% Brightness

Freq=1000 '1 kHz


HPWM LED,Duty,Freq