i have a problem.
i need to make a program for 16f84a when power turned on,it will show led pattern 1(on portb). Then when switch(porta pin 0) is pressed, portb will change to pattern2 and when pressed again,change to pattern3,then when pressed again,go back to pattern1.
thanks ian,
i have seen nigel's tutorial, but he uses multiple switch to change from one pattern to another.
i want to use only one switch (portA pin 0) and it will be able to change prom pattern to the next pattern.
hope you could help.
Start clrf count ;set counter register to zero
Read goto Table
Check btfss PORTA,0
goto Read
call Delay2
btfsc PORTA,0
retlw 0x00 <------------ Return from a call.....What call.
incf count, w
xorlw d'3' ;check for last (3rd) entry
btfsc STATUS, Z
goto Start ;if start from beginning
incf count, f ;else do next
goto Read
You're welcome to take a peek at something I did awhile back for a 16F628A. It may be worth studying for ideas. If you get stuck, please feel free to ask questions. Caveat - I have not tested this code on a real circuit...
The first byte in each FX sequence table is the number of steps in the sequence. This is calculated automatically (as long as you follow the same format shown in the example tables). Each of the following entries in an FX table represents a "step" in the sequence. That is, each entry or "step" contains a <pattern> byte, which is written to PORTB, and an <interval> byte which gives you the duration for that step (in 10 msec increments).
You'll notice that the push button switch is sampled continuously at 10 msec intervals during sequencer operation so you won't miss a switch press. The switch state logic may not be very intuitive but, basically, it detects a "new press" state and ignores the "continually pressed" state and the "release" state. When a "new press" is detected the code simply goes to the next FX sequence.