memory button


Closed Thread
Results 1 to 2 of 2

Thread: memory button

  1. #1
    Join Date
    Jan 2006
    Posts
    76

    Default memory button

    I am hoping to create a memory button, much like that on a car radio. If you set a value, then hold the memory button for 2 seconds, it stores the value. From that point on, you can recall the memory by pressing the memory button. I guess what I'm asking is how do you make the 2 second time condition to do go to the write action versus the read.


    thanks
    -brian

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Brian,

    Me again.
    Let me know if I'm giving too many answers ...

    Try this on for size
    Code:
    WriteDelay    CON  2000        ; ms
    But           VAR  PORTB.0     ; The Button
    LED1          VAR  PORTB.1     ; Read   indicator
    LED2          VAR  PORTB.2     ; Write  indicator
    DOWN          CON  0           ; input state when button is DOWN
    DelayCount    VAR  WORD        ; Write delay Counter
    
    Main:
        GOSUB CheckButton
    Goto Main
    
    CheckButton:
        IF But = Down then
            DelayCount = 0
            PAUSE 20                        ; debounce
            While But = Down
                PAUSEUS 980
                DelayCount = DelayCount + 1
                IF DelayCount >= WriteDelay then   ; Write detected
                    ; ---- do the Write operation here ----
                    TOGGLE LED2
                    ; -------------------------------------
                    While But = DOWN : Wend ; wait for button release
                    PAUSE 20                        ; debounce
                    RETURN
                ENDIF
            WEND                 ; button was released before timeout
            ; ---- do the Read operation here ----
            TOGGLE LED1
            ; ------------------------------------
            PAUSE 20                        ; debounce
       ENDIF
    RETURN
    Last edited by Darrel Taylor; - 12th February 2006 at 09:59. Reason: Changed Debounce
    DT

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. Need the code to write to a memory
    By Hamlet in forum General
    Replies: 0
    Last Post: - 20th August 2007, 00:22
  3. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 02:43
  4. Code check -- button not working
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 2nd March 2006, 22:43
  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 : 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