PWM with 12F675


Closed Thread
Results 1 to 6 of 6

Thread: PWM with 12F675

  1. #1
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579

    Default PWM with 12F675

    Hello everyone !
    Since I bought a lot of 12F675, I think to try another schematic : lighting LED using software PWM. I wrote this code ; when power on the PIC, the LED give 20 % of light ; if buton is pressed, the LED lights 40%, then 60%, then 80% and, finally, 100 %. In my dreams ...because in practice that don't work like I wish. I know that code is not good...so, please, help me with some suggestion. Thanks in advance.
    Attached Files Attached Files

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    The variable used in the CASE is specified in the SELECT statement.
    The CASE itself only needs the value to compare ...
    Code:
    select case counter
      case 1
        brightness=50
        pwm led,brightness,cycle
    
      case 2
        brightness=100
        pwm led,brightness,cycle
    
    ... etc.
    DT

  3. #3
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default

    Thank You Mr. D ! It's no e-beer on www enough for You as a gift !
    Yes, indeed, I am wrong with sintax...but still don't work proper.
    Maybe because of my poor english...
    So :
    -power on, LED lighting 20% (till power off or push button)
    -push button, LED lighting 40 % (same as previous)
    -push button, LED lighting 60% (same as previous)
    -push button, LED lighting 80% (same as previous)
    -push button, LED lighting 100% (same as previous)
    -push button, LED off till power on again or push button.
    It is possible ?

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Don't worry about your English.
    It's the BASIC Language that's subject...

    Let's see ... power-on 20%, push a button 40% .. etc.. etc... off after 100%
    Code:
    brightness = 51
    
    Main:
        WHILE buton
            pwm led,brightness,cycle
        WEND
        if brightness != 255
            brightness = brightness + 51
        else
            brightness = 0
        endif
        WHILE !buton
            pwm led,brightness,cycle
        WEND
    GOTO Main
    Last edited by Darrel Taylor; - 28th October 2009 at 16:52. Reason: modified to match the power-on request
    DT

  5. #5
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default

    Mr.Darrel, You are my guardian angel from far and away !!!
    Works verry good. Thank You from the bottom of my heart !
    P.S. : " if brightness != 255 then".

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    You're welcome fratello,

    P.S. : " if brightness != 255 then".
    Oops, that's what I get for not compiling it.
    <br>
    DT

Similar Threads

  1. Half-bridge PWM with a 16F684 ?
    By Byte_Butcher in forum General
    Replies: 7
    Last Post: - 17th January 2010, 22:18
  2. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  3. PWM 'channels ...what's that all about then!
    By HankMcSpank in forum General
    Replies: 5
    Last Post: - 23rd April 2009, 16:49
  4. PWM setting PIC16F887
    By Gevo in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th June 2008, 07:24
  5. Tidying Up PWM Routine
    By Tissy in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st February 2005, 00:26

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