Blink without the pause command


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    970


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by danielhr77 View Post
    I want to blink a LED without the pause command because I want to do other things and not stop the entire loop every time the LED blinks.
    SNIP
    Without the pause command the code could look something like this:

    count_on var byte
    count_off var byte
    pause_led var byte

    count_on = 0
    count_off = 0
    pause_led = 5000

    main:
    if count_on = 0 then
    high portb.0
    endif

    if count_on != pause_led
    count_on = count_on + 1
    endif

    if count_on = pause_led then
    low portb.0

    count_off = count_off + 1

    if count_off = pause_led then
    count_on = 0
    count_off = 0
    endif

    endif

    goto main:
    Daniel

    I can suggest (without interrupts) the following

    Code:
    counter:  var   word
    Led:        var   PortB.0
    
    counter =0
    main:   if counter < HalfSecondValue then
                counter=counter+1  ' increment the counter
             else
                counter = 0
                Led = !Led      ' toggle every half second
             endif
             '  do whatever you have to do here
            ....
            ....
            goto main           ' go back to the top
    Here, HalfSecondValue is something you will have to determine either by counting the machine cycles or experimentally(easier)

    Jerson

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Thanks to all for your help!

    I also found this from Darrel: http://www.darreltaylor.com/DT_INTS-18/blinky.html

    Regards!

    Daniel.

Similar Threads

  1. Delayed output 10 secs
    By lilimike in forum mel PIC BASIC Pro
    Replies: 37
    Last Post: - 14th October 2011, 07:28
  2. Old and beyond help ?
    By DavidFMarks in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 11th December 2008, 16:23
  3. Replies: 11
    Last Post: - 12th July 2008, 03:36
  4. Fade out LEDs question
    By Sam in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 22nd June 2008, 11:50
  5. Help Quick Need to make code smaller
    By Programmednew in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 25th January 2005, 04:46

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