LED fade without PWM command


Closed Thread
Results 1 to 8 of 8
  1. #1
    Nick's Avatar
    Nick Guest

    Default LED fade without PWM command

    I’m trying to get a LED to fade in and out with variable speed

    and without using PWM command.

    I intend to use a 8 pin PIC (12F629)

    Where can I find some code sample to accomplice a smooth,

    100 % fade in and out with variable speed set by a variable?

    Any help will be appreciated.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    dowload this code i do many weeks ago based on TIMER1

    PWM, SERIN/SEROUT are really often ask here. If u do a search, you'll probably found a bit less hits than the quantity of thread
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Nick's Avatar
    Nick Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks Steve.

    I'm using PBP 2.45a to compile your code
    and I'm getting an error:
    "59: [235] Opcode Expected Instead of '_config'
    Does the code compile for you?

  4. #4
    Nick's Avatar
    Nick Guest


    Did you find this post helpful? Yes | No

    Default

    I tried the suggested PWM built in PBP and it works pretty good.
    Here is the code I used to get a nice ramp up and down even with
    high brightness LEDs which are harder to control linearly.


    led VAR PORTB.5
    steps VAR WORD
    cycles CON 2

    ' Change limits for steps to play around 0 or 100% brightness
    ' Change steps for different duration of ramps
    ' Works good even with high brightness LEDs, harder to control linearly


    fade:

    up:
    For steps=0 TO 255
    PWM led,steps,cycles
    Next
    High led

    Pause 2500

    down:
    For steps=255 TO 1 STEP -1
    PWM led,steps,cycles
    Next
    Low led

    Pause 2500


    GoTo fade

    End

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Nick
    Thanks Steve.

    I'm using PBP 2.45a to compile your code
    and I'm getting an error:
    "59: [235] Opcode Expected Instead of '_config'
    Does the code compile for you?
    Nick this is caused by the @config line... simply remark this line.. This line set the configuration fuses for your PIC. If you're using PM instead of MPASM this will gives you this error message. See the FAQ about configuration fuses. Really handy stuff.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Nick's Avatar
    Nick Guest


    Did you find this post helpful? Yes | No

    Default

    I made the changes and everything works fine
    Thanks again Steve.

  7. #7
    ollim13's Avatar
    ollim13 Guest


    Did you find this post helpful? Yes | No

    Red face Circuit

    Hallo I´m new in programming, is it possible to get the circuit for the programm from Nick.
    Thank you.
    Olli

  8. #8
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Olli,

    is it possible to get the circuit for the programm from Nick.
    All you have to do , is connect a diode to the pin in which you are working with... connect up your +/- voltage, and presto. No circuitry per se is required...

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 06:14
  2. Free Project - 245 LED Display
    By T.Jackson in forum Code Examples
    Replies: 221
    Last Post: - 16th August 2009, 04:59
  3. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  4. Strangw results when using PWM command
    By malc-c in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 10th July 2006, 12:14
  5. Fade out an LED using PWM?
    By RossW in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 6th August 2004, 19:59

Members who have read this thread : 1

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