Ok, a bit more reading .... it seems the button command will be perfect for needs.
My initial problem is that it only acts on PORTB pins (& the Pickit 2 board has its switch wired to RA3). therefore I've rigged up a pull up resistor onto pin RB7 & a small switch which goes to ground (therefore puts 0V onto RB7 when this new switch pressed). However RB7 is being held low all the time.
I'm figuring this must be something to do with the .inc file again (I've rechecked my wiring - it's fine ...10k resistor between RB7 & the 5V rail....and a normally open switch going from RB7 to ground). I chose RB7 for my new switch as it seemed to have the least happening! On the datasheet it's listed as RB7/TX/CK ...how can I be sure it's being used as an input pin only (& not being overridden by one ithe pins other purposes)
Does anyone have any ideas why my RB7 might be permanently low.
Here's the small bit of code I'm using...
@MyConfig = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON
@MyConfig = MyConfig & _MCLRE_OFF & _BOR_OFF
@ __config MyConfig
DEFINE OSC 4
ANSEL=0 ' all digital
ANSELH=0 ' analog module disabled
CM1CON0=0 ' dunno what this line does!
CM2CON0=0 ' nor this one!
TRISA=%11111111 ; set all Port A pins as inputs
TRISB=%11111111 ; set all Port B pins as inputs
TRISC=%00000000 ; set all Port C pins as outputs
B0 VAR BYTE ;creates a variable as needed for the button command below
B0 = 0 ; give it a value of zero (as per the command's reference)
LED1 var PortC.0 ' ; assign a more usable name to the first LED port
start:
LOW LED1 ; turn the first LED off
BUTTON 7, 0, 255, 0, B0, 1, Loop ; monitor the switch on RB7 for 0V,
;if this condition is net, then go to next
next:
high LED1 ; turn the first LED on
PAUSE 1000 ; wait one second
goto start ;start over
End
Bookmarks