Help with pic 12f629


Results 1 to 40 of 53

Threaded View

  1. #40
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Hi,

    May be that one ???

    Code:
    '****************************************************************
    '*  Name    : Bôton.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 17/09/2010                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    DEFINE OSC 4
    DEFINE BUTTON_PAUSE 10    ' 10 is default value
       @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
     
        cnt VAR BYTE
        delay var byte
     
        boton VAR GPIO.2
        mosfet VAR GPIO.1
     
     
     '   ANSEL           = 0     '12F675 for test
        CMCON           = 7
        OPTION_REG.7    = 0    'Pullups  enabled
        WPU             = %00000100
     
        cnt             = 0
        GPIO            = %00000110                 ' Nosurprise startup ...
        TRISIO          = %00000100 
     
    '******************************************************************************
    Detect: 'Button presses W/Debounce
    '
    delay = 0
    BUTTON Boton ,0,255,0,delay,1,pressed
        Pause 20                                    ' Slow Things down
        GOTO Detect
     
    '******************************************************************************    
    Pressed:  ' Some > 10ms press detected
        IF cnt < 3  Then
     
            cnt = cnt + 1
     
        ELSE
     
            cnt = 0
            LOW mosfet
            PAUSE 1000
     
        ENDIF
     
    WHILE !Boton : WEND                                ' Wait Boton release !!!    
    goto detect
     
    END
    Alain
    Last edited by Acetronics2; - 18th September 2010 at 15:42. Reason: Inverted Mosfet on/Off
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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