Single button function


Results 1 to 40 of 41

Threaded View

  1. #12
    Join Date
    Jun 2005
    Location
    Germany
    Posts
    6


    Did you find this post helpful? Yes | No

    Question Button code doesn't work

    Say hello to everyone,

    where is the fault in this example:


    ButtonPress var BYTE ' Button Counter Variable

    LongPress con 20 ' Change this value for desired SET
    ' function trip-point in 50mS steps
    ' Currently set for 1 Second


    MainLoop:
    LCDOut $FE,1,"Go Press..."
    ButtonLoop:
    Gosub GetButton
    If ButtonPress>0 then
    If ButtonPress=1
    LCDOut $FE,1,"Short Press"
    else
    LCDOut $FE,1,"Long Press"
    endif
    Pause 1000
    Goto MainLoop
    endif
    Goto ButtonLoop

    '
    ' Subroutine weighs-up users finger
    ' in multiples of 50mS
    ' Constant LONGPRESS determines boredom level
    ' -------------------------------------------
    ' on Exit...
    ' ButtonPress=0 - No Press
    ' ButtonPress=1 - Short Press
    ' ButtonPress=2 - Long Press
    GetButton:
    ButtonPress=0
    While MyButton=0
    If ButtonPress<255 then ButtonPress=ButtonPress+1
    Pause 50 ' This is also our Debounce value
    If ButtonPress=LongPress then LCDOut $FE,1
    Wend
    If ButtonPress>0 then
    If ButtonPress=>LongPress then
    ButtonPress=2
    else
    ButtonPress=1
    endif
    endif
    Return

    I have this Sample code compiled and get this error message:

    ERROR Line 18: Bad expression or missing THEN, (Button_01.php)

    See attachment

    I am here new and am pleased about every help.

    Konrad
    Attached Images Attached Images  

Similar Threads

  1. Sony SIRC IR Issue
    By Ryan7777 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 8th August 2015, 08:10
  2. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 02:43
  3. Code check -- button not working
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 2nd March 2006, 22:43
  4. Pushbutton code routine suggestions?
    By jessey in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd September 2005, 01:02
  5. Button subfunction 16F628
    By Jųan in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 19th August 2005, 16:44

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