Before i get flamed, i have read the data sheet many times, but its perhaps that i am not understanding it !
If i change the Swicth input to say PORTC.1, all works fine, on PORTA.1 it does not.
I am missing something in this code. I have been trying for a day and it is driving me mad !!
Many thanks,Code:Clear ADCON1 = %00001111 DEFINE OSC 20 DEFINE LOADER_USED 1 ' ---------- [ I/O Definition ] ---------- TRISA = %00000011 ' Set PORTC (0-2 input) rest Outputs TRISB = %10000001 ' Set PORTB (0)INPUT (1-5)OUTPUTS TRISC = %01000111 ' Set PORTC (0-2 input) rest Outputs PORTB = 0 Switch VAR PORTA.1 ' use a pin with Schmitt Trigger input RedLED VAR PORTB.1 X VAR word Presses VAR BYTE LOOP VAR BYTE confirm_flag var byte Main: if Switch = 1 THEN WHILE Switch = 1 : WEND COUNT Switch, 1500, Presses BRANCHL Presses,[routine1, routine2, routine3] GOTO MAIN endif GOTO Main '-------------- routine0: ' button was not pressed again ' or pressed more than 3 times GOTO Main '-------------- routine1: ' pressed once HIGH REDled PAUSE 500 LOW REDled GOSUB Confirmation if confirm_flag = 1 then gosub flash Goto main '-------------- routine2: ' pressed twice FOR X = 1 TO 2 HIGH REDled PAUSE 500 LOW REDled PAUSE 500 NEXT X GOSUB Confirmation if confirm_flag = 1 then gosub flash GOTO Main '-------------- routine3: ' pressed thrice FOR X = 1 TO 3 HIGH REDled PAUSE 500 LOW REDled PAUSE 500 NEXT X GOSUB Confirmation if confirm_flag = 1 then gosub flash GOTO Main Flash: For loop = 1 to 10 Redled = 1 Pause 50 Redled = 0 Pause 50 Next Loop Return Confirmation: confirm_flag=0 x=0 WHILE (x<300) and (confirm_flag=0) Pause 10 'check for button every 10ms if Switch = 1 then confirm_flag = 1 ' if button pushed then set the flag x=x+1 ' increment the pause counter WEND Return
Steve


				
				
				
				
			

Bookmarks