You guys crack me up !
Ok' I'm working my way through this version using the 16F873A, but I've hit a small issue which is so basic I can't see why it responds the way it does (it worked with the 16F628a).
I have set port A to all inputs and added
Code:
SW1 var PORTA.2 ;pattern selection switch
I have a 10k pull up resistor between pin 4 (RA2) and +5v with a tactile switch between pin 4 and GND.
I've added the code
Code:
if SW1=0 then swcount=swcount+1 ;check to see if up button pressed, if so add 1 to swcount
pause 60 ;debounce delay
If swcount>7 then swcount=1 ;error trap for exceeding max patterns
So in therory if the switch (sw1) is low then swcount is increased by 1, until it is > than 7 and if so then its swcount is reset to 1. This way the pattern is selected by pressing the switch.
However in practice, the PIC simply ignores any input on RA2, but more confusingly, it runs each pattern once in sequence, ie it cycles through the patterns as if the button is being pressed, so swcount must in some way be changing as the remainder of the code works if the above lines are remed out and swcount is manual set to 1, 2, 3 etc, which results in just the selected pattern running.
Code:
Pot PORTA.1,scale,D ;used to read value from 10k pot and set the speed
read patt[swcount],steps ;read the first value of the selected patter and place it in the variable steps
for C = 1 to steps ;for / next loop
READ PATT[SWCOUNT]+ C,PORTB ;reads the step value for selected pattern and send it to PORTB
PAUSE D ;delay for speed
NEXT
GOTO MAIN
Its probably me having a blonde moment (no offence to any fair haired madiens out there
) - but can anyone shed some light why this isn't working.
Bookmarks