One pres switch in pic basic help!!!!


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2010
    Posts
    43

    Default One pres switch in pic basic help!!!!

    Hay,all!!!!
    Can somebody help me in Picbasic programing!
    I need some code to switch with one button,to change to next program!
    Example:
    program1:
    some doing
    goto program 1

    program2:
    some doing
    goto program2

    program3:
    some doing
    goto program3 .......


    and can some help me how I write some code for the button,when I press button ONE TIME,to I change to
    program1
    program2
    program3......

    to change program,when I PRESS MY BUTTON ONE TIME,TO AUTOMATIC GO TO CHANGE PROGRAM!

    If some body can help me,how i do that un PIC BASIC!

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    You have posted the same thing in two sections.
    Pic Basic and Pic Basic Pro.
    Which one are you using ?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    May 2010
    Posts
    43


    Did you find this post helpful? Yes | No

    Default Pic basic

    Sory, beacuse post in two section
    i use pic basic

  4. #4


    Did you find this post helpful? Yes | No

    Default Program selection by button press

    Try this idea, it works with PBP in a PIC18F4620 and should work with any PIC that has EEPROM.

    I set a byte variable "ProgramState" to 1 in a data statement and write this to EEPROM when the program is loaded into the PIC.

    At power up, the code reads the value stored in ProgramState, EEPROM location 0, here set to 1, and jumps to the appropriate code block.

    MAIN:
    READ 0, ProgramState
    If ProgramState = 1 then RunCode1
    If ProgramState = 2 then RunCode2
    If ProgramState = 3 then RunCode3

    If ProgramState > 3 then
    write 0, 1 'reset ProgramState to first code block
    goto MAIN
    endif

    RunCode1:
    execute codeblock 1
    if ButtonDown = 1 then
    write 0, 2
    endif
    goto MAIN

    RunCode2:
    execute codeblock 2
    if ButtonDown = 1 then
    write 0, 3
    endif
    goto MAIN

    etc

    HTH
    BrianT

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