Trying to make code smaller


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    I don't know if the setting are correct since I have never used this chip.

    But assuming setting OK then this code will work as you want;
    Code:
    Loop:
    pause 100
    If button1=0 then 
    X=X+1
    goto Start
    endif
    goto Loop
    
    start:
    For A0 = 0 to X
    Toggle Led
    Pause 50000
    next A0
    if X=255 then X=254
    goto Loop
    
    end
    Flashing will increment by one at every press upto 255.

    Now, you add a second button and relative code for decrementing the variable X.

    Al.
    All progress began with an idea

  2. #2


    Did you find this post helpful? Yes | No

    Default

    When you are using Toggle command in an indexed loop you must double your index to get a certain number of blinks.
    In your case the index variable A0 should be 20. You also need to know what the status of your LED output is for a good control over the number of blinks and add or eliminate unnecessary pauses.

    Hope this helps.

    Regards,

    Nick

Similar Threads

  1. Code doesn't work on 16F648A
    By Mr_Joe in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st September 2018, 23:09
  2. I2C Master/Slave 16F88/16F767 working code
    By DanPBP in forum Code Examples
    Replies: 2
    Last Post: - 23rd October 2012, 23:31
  3. Can someone help me make a code for this:
    By joseph in forum mel PIC BASIC
    Replies: 0
    Last Post: - 29th April 2009, 19:58
  4. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 22:55
  5. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 09:26

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