Fade out an LED using PWM?


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Ross,

    there is an easy way to achieve that "fading effect"
    even on a PIC with no Hardware PWM, use Software PWM:

    Duty VAR BYTE
    Cycle VAR BYTE
    LED VAR PortB.1

    ' changing the value for "Cycle" will change the time it takes
    ' to fade from 100% to 0%

    Cycle=10

    Loop:
    For Duty=255 to 0 Step -1
    PWM LED,Duty,Cycle
    Next
    Pause 3000
    GOTO Loop


    rgds
    Last edited by NavMicroSystems; - 5th August 2004 at 12:02.

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 07:14
  2. Free Project - 245 LED Display
    By T.Jackson in forum Code Examples
    Replies: 221
    Last Post: - 16th August 2009, 05:59
  3. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 07:03
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 03:30
  5. LED fade without PWM command
    By Nick in forum mel PIC BASIC
    Replies: 7
    Last Post: - 29th June 2005, 21:56

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts