' BAR_GRAF.BAS ' ' Illustrates how to shift n bit word out on shift register, beginning ' with most significant bit. This might be used to control a number of ' devices using the output of the shift register as is described in the ' Parallel Port Manual - Vol 2. ' ' This program assumes a 10 bit shift register is on pins 0 (CLK) and 1 ' (Data) which is controlling a 10 segment bar graph LED. ' ' Peter Anderson, MSU, 17 Nov '96 symbol SHIFT9=%100000000 symbol offset=b2 symbol n=b3 symbol bit=b4 symbol pattern=w4 dirs=%00001111 pins=%00000000 main: for offset=0 to 10 'walk the bar graph up lookup offset, ($0,$1,$3,$7,$f,$1f,$3f,$7f,$ff,$1ff,$3ff), pattern gosub invert 'invert the pattern to light LED with a logic zero gosub out_pattern 'output the pattern pause 1000 'pause to admire next for offset=10 to 0 step -1 'now walk it down lookup offset, ($0,$1,$3,$7,$f,$1f,$3f,$7f,$ff,$1ff,$3ff), pattern gosub invert gosub out_pattern pause 1000 next goto main 'continuous loop invert: 'performs ones compliment. pattern=pattern^$3ff return out_pattern: 'outputs pattern beginning with most sig bit for n= 0 to 9 bit=pattern/SHIFT9 'get most significant bit gosub clock 'send it to shift register pattern=pattern*2 'shift remainder to left next return clock: 'sets pin1 to bit value and provides clock pulse pin0=0 pin1=bit toggle 0 toggle 0 debug bit return