User Selectable LED Brightness


Results 1 to 7 of 7

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    Try this
    Code:
    TRISB = %10000001   ' Set PORTB (0)INPUT (1-5)OUTPUTS
    CMCON = 7 
    
    SecSwitch   VAR PORTA.5
    Red         VAR PORTB.1
    
    Bright      VAR Byte
    storedloop  VAR Byte
    
    bright = 1
    
    main:
        pwm red, bright, 5
    
        If secswitch = 0 then 
           If bright < 255 then bright = bright + 1
           If bright = 255 then gosub flash
        endif
    
    Goto main
    
    Flash:
    For storedloop = 1 to 3
            High red
            Pause 100
            Low red
            Pause 100
    Next storedloop
    Return
    As i'm using the MCLR as an input for the switch, is there a way to set this fuse in PBP, i'm using MeLabs Serial Programmer. I have to set it manually each time, which is a pain.
    It depends on your PIC type and the assembler you are using (PM, or MPASM)

    see: Presetting Configuration Fuses
    Last edited by NavMicroSystems; - 8th April 2005 at 16:27.
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



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. new and need help
    By smeghead in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd November 2008, 20:19
  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 : 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