MyButton var PortB.3
LED var PortB.4
TRISB = %00001000
Loop:
If MyButton=0 then
Toggle LED
While MyButton=0:Pause 100:Wend
endif
Goto Loop
End
Try the above and report back what the result is...
MyButton var PortB.3
LED var PortB.4
TRISB = %00001000
Loop:
If MyButton=0 then
Toggle LED
While MyButton=0:Pause 100:Wend
endif
Goto Loop
End
Try the above and report back what the result is...
'PIC 16F84A
DEFINE OSC 4
TRISA = %000001
TRISB = %11111100
I VAR BYTE
PAUSE 200
MAIN:
IF PORTA.0 = 1 then SWITCH_LED
goto main
SWITCH_LED: IF PORTA.0 = 0 THEN SWITCH_LED_INSTANT
FOR I = 0 TO 10
IF I < 10 AND PORTA.0 = 0 THEN SWITCH_LED_INSTANT
PAUSE 100
NEXT I
IF PORTA.0 = 1 THEN SWITCH_LED_DELAY
goto main
SWITCH_LED_DELAY: TOGGLE PORTB.0
PAUSE 10
AVOID_LED_BLINK: IF PORTA.0 = 1 THEN AVOID_LED_BLINK
PAUSE 10
GOTO MAIN
SWITCH_LED_INSTANT: TOGGLE PORTB.1
PAUSE 10
GOTO MAIN
I'm also a new one with de pic chips, can I use this also for a 16F628A chip??
grz Jan
Hello Melanie,
Your piece of code didn't work until I... grounded PORTB.2.
So I tried my code and it worked well too.
I didn't expect this component to be so sensible to the electric field around the pins.
I won't forget this lesson, for sure ;-)
Roger
If you are meaning "can you use the button command with the 16f628a chip, then the answer is yesOriginally Posted by JARI NETWORKS
![]()
Bookmarks