Button


Closed Thread
Results 1 to 6 of 6

Thread: Button

  1. #1
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302

    Default Button

    Code:
        if PORTB.5 = 1 and PORTB.7 = 1 then    
    	   WRITE W1, TMP_LO		   
    	   WRITE W1+1, TMP_HI			
    	   LCDOUT $FE, 1, "     STORE    " 
    	   PAUSE 1000
    	   menu = 2
    	   GOTO MAIN  
    	endif
    
               GOTO MAIN
    When PORTB.5 = 1 go to main and if PORTB.5 = 1 and PORTB.7 = 1
    write to the memory and after go to main.
    Now, i want if PORTB.5 = 1 for pause = 100 to go to to main and if
    PORTB.5 = 1 for long time and if PORTB.7 = 1 go to write.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    OK let's see if i understand your requirement.
    1. When ONLY PORTB.5 = 1 this should go to main
    2. if PORTB.5 = 1 and PORTB.7 = 1, this should write to the memory and after go to main.

    but you lost me with the pause 100... i may think you want to perform another operation if PORTB.1 have been hold more than 100 mSec... but not sure.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    OK let's see if i understand your requirement.
    1. When ONLY PORTB.5 = 1 this should go to main
    2. if PORTB.5 = 1 and PORTB.7 = 1, this should write to the memory and after go to main.

    but you lost me with the pause 100... i may think you want to perform another operation if PORTB.1 have been hold more than 100 mSec... but not sure.
    I have two buttons . One to portb.5 and another to portb.7
    Yes ,when i press momentarily the button1 then go to main, and when i press button1 for a long time and when afterwards press button2, then write to the memory.
    Sorry fo my bad english.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Don't worry about your English Savnik. I understand how hard it is to explain something when English is not your native language. I'm French... but Canadian

    OK let's see one method to do that... yeah the saturday pm one solution
    Code:
            PORTB = 0
            TRISB=%10100000
            EEPROMWriteMode VAR PORTB.0
            WriteToEEPROM   var PORTB.1
            MainLed         var PORTB.2
            
            Delay var word
    
    Main:
        MainLed = 1
        if PORTB.5 = 1 THEN GOSUB P_B_sub
        goto main
        
    P_B_Sub:
        mainled = 0
        delay = 0
        while (PORTB.5 = 1) and (Delay<1000)
            pause 1     
            delay=delay+1
            wend
        if delay<1000 then return
        
        eepromwritemode=1
        delay = 0
        while (PORTB.7 = 0) and (DELAY<1000)
            pause 1
            delay=delay+1
            wend
    
        if (delay<1000) then
            writetoeeprom =1
            endif
            
        pause 1000
        eepromwritemode =0
        writetoeeprom = 0
        return
    there's still the Timer Interrupt solution...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Thank you.Your code help me to solve my problem.
    I use this code:
    Code:
       	if PORTB.5 = 1 then
            while (PORTB.5 = 1) and (Delay < 1000)
                menu = 6
                pause 1     
                delay = delay + 1
                wend
            if  delay < 1000 then
                delay = 0
                GOTO MAIN
            else
                delay = 0
                WRITE W1, TMP_LO		   
    	        WRITE W1+1, TMP_HI			
    	        LCDOUT $FE, 1, "     STORE    " 
    	        PAUSE 1000
    	        menu = 2
    	        GOTO MAIN
            endif
        endif

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Good, enjoy!

    and mmm... παρακαλώ!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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. Button Push within 3 second Window
    By Tissy in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 22nd December 2005, 10:06
  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