Latched buttons


Results 1 to 10 of 10

Thread: Latched buttons

Threaded View

  1. #7
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    I just wrote this program to start learning on interrupt, as expected... it didn't work


    Code:
    @ device pic12F675, intrc_osc_noclkout, wdt_on, mclr_off, protect_off
    
    DEFINE OSC 4
    
    trisio  =%00110000
    ansel   =%00000000  
    cmcon  =%00000111  'Comparators Off
    intcon  =%10001100  'interrupts enable / tmr0 overflow / gpio change interrupt enable
    OPTION_REG = %11010101    ' Set TMR0 configuration
    
    but1    var gpio.4
    but2    var gpio.5
    led1    var gpio.1
    led2    var gpio.2
    ledwork var gpio.0
    
    but1st  var bit
    but2st  var bit
    
    conta   var byte
    
    
    on interrupt goto interrupcion
    
    loop:
    
    for conta=0 to 255 step 16  'working led rise routine
        pwm ledwork, conta, 10
            disable
            if but1st=1 then
                but1st=0
                high led1
            endif
            if but2st=1 then
                but2st=0
                high led2
            endif
            enable
        
    next conta
    high ledwork
    
    for conta =0 to 100
        pause 10
    next conta
    
    low led1    'set status buttons leds off
    low led2
    
    for conta=0 to 255 step 16  'Fall routine
        pwm ledwork, 255-conta, 10
            disable
            if but1st=1 then
                but1st=0
                high led1
            endif
            if but2st=1 then
                but2st=0
                high led2
            endif
            enable
       
    next conta
    low ledwork
    
    low led1   'set button status leds off
    low led2
    
    goto loop
    
    
    disable
    interrupcion:
        but1st=but1
        but2st=but2
        intcon  =%10001101
        resume
    enable

    Any help appreciated


    Pablo
    Last edited by peu; - 24th January 2006 at 15:08.

Similar Threads

  1. In Circut Debug (ICD) buttons palet is disable for 18F2620
    By muskut in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th June 2010, 05:21
  2. Button command question
    By aherrera in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 31st August 2009, 08:44
  3. Buttons
    By WarPony in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 16th May 2008, 01:47
  4. 6 Buttons
    By Johansch in forum General
    Replies: 3
    Last Post: - 4th July 2007, 15:21
  5. Buttons are driving me nuts
    By Doormatt in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 21st May 2007, 23:09

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