in your case i see few mistake.
1. Is your PushButton is connected to PORTA. In case you set TRISA=0... PORTA is now output... so you cannot get from PORTA.
2. PIC16F627 have internal analog comparator that must be turn off when you don't using them CMCON=7
3. i've never use BUTTON statement. I think this fuction eat too much code space for an simple task. i post you my way to handle pushbutton
Code:
CMCON=7 ;Disable analog comparator
TRISB=0 ;set PORTB to output
TRISA=255 ;set PORTA to input
PushButton VAR PORTA.0 ;push button connected to RA0
PORTB=0 ;turn off PORTB... in case only
start:
While Pushbutton=0 ;wait for Push button action
;you can also use While NOT PushButton
Wend
While PushButton ; wait for push button release
Wend
pause 50 ; debounce time...cheap but work
;once the debounce time is finish... use your code
PORTB = 255 ' Turn ON diodes on PORTB
PAUSE 1000 ' Wait for 1 second
PORTB = 0 ' Turn OFF diodes on PORTB
pause 1000
GOTO Start
I hope this help you. Sorry if i didn't use BUTTON statement
Last edited by mister_e; - 5th November 2004 at 15:34.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks