Hey, I am trying to learn how to use the button command but I have not been able to get it to work. My workaround is not working either. What I want to do is start the flashing loop on GP0 after the button on GP1 is pushed. I think my problem is in the Loop1 but I dont know how to fix it. It just goes directly to flash loop2.

Can anyone show me how to do this using the button command? I will keep trying but it just passes it right up.

Thanks,

Jeff






'INITIALIZE PINS and PORTS:

SYMBOL ANSEL = $9F '$19 IS ANSEL REGISTER
POKE ANSEL, 0 'MAKE PIN DIGITAL, NOT ANALOG

SYMBOL ADCON0 = $1F 'TURN OFF A/D ON PIN4. (DEFAULT IS ON)
POKE ADCON0, 254 '$1F IS ADDR OF A/D REGISTER. 10011111 (7)
'ARE BITS TO TURN A/D ON AND OFF

SYMBOL TRISA = $85 'SETUP PINS DATA DIR I/O
POKE TRISA, 255 'MAKE DATA I/O GP0 AN OUTPUT, GP1 AN INPUT
'AND MAKE GP1 AN INPUT (ALL OTHERS ARE OUTS)

symbol PORTA = $05 '$05 IS OUTPUT DATA REGSITER
POKE PORTA, 0 'TURN OFF ALL BITS

Loop1: PEEK PORTA, BIT0 'COPY PORTA REG, PUT IN VARIABLE B0
IF BIT0 = 1 THEN LOOP1 'WHEN BUTTON IS PUSHED, INPUT GOES LOW


loop2: High 0 'Turn on LED connected to GP0
Pause 500 'Delay for .5 seconds

Low 0 'Turn off LED connected to GP0
Pause 500 'Delay for .5 seconds

Goto loop2 'Go back to loop and blink LED forever