LED crazy


Closed Thread
Results 1 to 3 of 3

Thread: LED crazy

  1. #1
    Join Date
    May 2008
    Posts
    9

    Question LED crazy

    Hi all I'm new here to the forum.
    I download the demo ver. of the picbasic pro
    and was able to make some leds blink with a
    16f84a chip.
    Is there a way to make a led dim to low and then
    dim up to high?
    I tryed to make some wild program to do this
    but it is full of errors.
    I know basic some what and have some know how
    in programing.
    A little.
    For some reson it dont like my veriables.
    Can anyone show me the picbasic code to do this?
    Thanks for any help!

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default

    Hi,
    There's lots of ways to acomplish what you want, most of them involve some kind of PWM generating. Generating that PWM can be done with PBP's PWM command for a software-only-aproach or by the PICs hardware CCP module.

    If dimming that LED up and down is all you want then something quick and dirty like this might do the trick:
    Code:
    TRISB.7=0     'Set PortB.7 to output, connect LED here.
    DutyCycle VAR byte
    
    Start:
    For DutyCycle = 0 to 255
     PWM PortB.7, DutyCycle, 10
    Next
    
    For DutyCycle = 255 to 0 Step -1
     PWM PortB.7, DutyCycle, 10
    Next
    
    Goto Start
    That's one way...also have a look at the HPWM command and search this forum for Darrel Taylors software PWM routines.

    /Henrik.

  3. #3
    Join Date
    May 2008
    Posts
    9


    Did you find this post helpful? Yes | No

    Smile led crazy

    Thanks HenrikOlsson
    Thats what I was looking for.
    Very nice of you to help me.
    Now I can take this code you made
    and mess with it.
    You know like add more leds and mess with
    the fade time.
    Thanks again!

Similar Threads

  1. 12f675 making me a crazy person
    By Meriachee in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 16th September 2009, 21:55
  2. new and need help
    By smeghead in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd November 2008, 20:19
  3. For next loop using: Led var Byte
    By quester in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th March 2008, 10:16
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  5. can't even flash an LED
    By bruno333 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 28th April 2005, 13:27

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