? on code


Closed Thread
Results 1 to 11 of 11

Thread: ? on code

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    How are you setting B.1 low or high ?
    are you using a button?

    It looks like your "Switch" bounces when toggling.
    means it very quickly changes between on and off before it reaches its final position.

    The program is that fast that it detects this change.

    you need to eliminate that "Key-bounce"

    here is one possible way:

    i Var Byte

    Loop:

    If PortB.1=1 Then 'Check HIGH on B.1
    Pause 500 ' wait 500ms (you can certainly decrease the Pause time

    If PortB.1=1 Then ' Is B1 still HIGH ?

    High PortB.0

    for i=1 to 60
    Pause 1000
    next

    Low PortB.0

    EndIf
    EndIf


    DoNothing:
    If PortB.1=1 Then
    Goto DoNothing
    EndiF

    Goto Loop


    Key bounce is actually a "mechanical" problem you have to think of when working with buttons.

    Your other questions were regarding basic BASIC stuff.

    Now that you have got some examples try to modify the code.
    i.e. use the BUTTON statement.
    Last edited by NavMicroSystems; - 7th March 2004 at 21:33.

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 22:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 22:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 9th December 2008, 00:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 09:26
  5. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 18:23

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