Simple bit bang method to vary LED brightness using POT

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

User avatar
Valued Contributor
Valued Contributor
Posts: 8479
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2435 times
Been thanked: 3491 times

Simple bit bang method to vary LED brightness using POT

Postby medelec35 » Thu Jul 02, 2009 10:26 pm

This was created with Flowcode V4 to vary LED brightness from really Dim to bright. Method uses a pot to control duty cycle of a bit bang PWM.
Target Chip = 16F887
Osc = int 4MHz
Approx PWM Freq= 193 Hz

As usual using Flowcode the target chip can be changed. However, if using a different chip, then config and osccon will require changing/removing to suit new target.
Please bear in mind this was created for a chip running at 4MHz. If run at a different frequency, then will not function as well.
This is my 1st bit bang attempt with a pot, although works really well,I'm sure it can be improved. (but only a little bit :P )
(7.5 KiB) Downloaded 593 times
These users thanked the author medelec35 for the post:
zen (Tue Jan 04, 2011 6:54 am)
Rating: 5.26%

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.