Shift Register

Shift Register

EOS

Instruments

webpages and Eos image copyright 2016   M  Nealon

Part A, Hardware.

Hardware construction exercise, and a PicAxe programming exercise. 

 

The PicAxe 08M2 microprocessor drives a shift register in order to illuminate eight LED’s.  The illumination patterns are designed by individual programmers.  Various patterns may be switch selected. 

 

The number of such patterns is limited by the imagination of the programmer or the size of the microprocessor.  The speed with which the processor runs through each pattern is varied by adjustment of a potentiometer.

 

First the hardware is laid out, assembled and soldered together.  Then the program is written and downloaded onto the microprocessor.

Since this project is based on the PicAxe 08M2 microprocessor, the Proto Board Kit is the simplest method to arrange a circuit for downloading the program.  Also, there happens to be just enough space on the board to place the shift register and debounce circuit.

This Proto Board is then mounted on a breadboard along with the LED’s and their corresponding limiting resistors.  The pattern selector switch and speed controlling potentiometer are also mounted on the breadboard.

Bill of Materials

PicAxe 08M2 Proto Board Kit and 08M2 microprocessor

10 kΩ resistor

560 Ω resistor

1 μF capacitor

Momentary contact switch

5 kΩ 10-turn potentiometer

SN54HC595 shift register, Texas Instruments

16-pin DIP socket

(8) 470 Ω resistors

(8) LED’s

Battery holder, 4.5 V

Breadboard and other mounting hardware

Part B, Software.

The overall plan of the program may be outlined as a flowchart in the PicAxe Programming Editor.  Generally, refinements to the plan must be made by hand in Basic language. 

PicAxe 08M2

The breadboard.

 

The blank Proto Board is shown.  The cork is used to underlie the circuit board.  The LED’s and resistors are soldered onto the 3 x 8 array of brass-plated nails.  The battery holder is attached. 

The program runs continuously in a loop.

 

An eight-bit byte is used as a single on/off  sequence for lighting the eight LED’s.  Let’s call a collection of these sequences a “pattern”.   The patterns may have as many or as few sequences as desired by the programmer.  The small 08M2 microprocessor is large enough to program several patterns, if desired.  The momentary contact switch is used to step through these patterns.

 

The simplest method to keep track of these various patterns is to use an index.  An interrupt command, then, can be used to read the momentary contact switch.  Upon each press of the switch, the index increments and the next pattern is sent to the LED’s.  After the last pattern is displayed, the index is reset to zero.

 

The time during which the LED’s stay lit is set inside the programmed routine.  Periodically, the program reads the input pin attached to the speed control potentiometer and adjusts this delay time.

 

Perhaps the most efficient method of sending a sequence to the shift register is to call a subroutine.  In the subroutine, each bit is CLOCKED in series along the DATA line.  The shift register stores all eight bits in temporary registers, then on LATCH command from the microprocessor, will shift the eight bits in parallel to its eight outputs, thus lighting the LED’s.

Overall scheme for the program in Flowchart form.

 

This program allows for eleven patterns.  A variable, with default name “varG”, is used for the index.  The box “mainprogram” initiates the program and consists of code written in Basic language.

 

If the momentary contact switch is pressed twelve times, all LED’s are turned off and the index is reset to zero.  The program then loops, waiting for the switch to be pressed again.

Interrupt routine.

 

The interrupt command works only if it is “enabled”.  This command is disabled each time it is used so it must be enabled each time the switch is pressed.  The first enable is in the Basic block “mainprogram”.  The enable command is repeated at the end of the interrupt routine.

 

The interesting thing about the interrupt command is that it may be use on more than one pin at a time.  The logic of using multiple pins is that you must “mask” the inputs; that is, you must tell the processor which pins to look at for possible interrupts.  Also, you may tell the processor to interrupt on a “high” input or “low” input.  Furthermore, you must tell the processor whether you wish to interrupt the current program if all (AND) of the selected pins are in the condition you have set, or if any are in the conditions you have set.  For use of a single pin, the OR condition is used by default.

 

In this interrupt routine, the “C.3 high?” and “C.3 low?” questions are a software debounce.  This is not really necessary since we have the hardware debounce, so it may be deleted if a few extra lines of code are needed for something else.

 

Each time an interrupt is called, the program returns to the place where it was interrupted.

Examples of patterns.

mainprogram:

let dirsC = 1

 

symbol dataline=c.0

symbol clockline=c.4

symbol latch=c.2

symbol switch1=c.3

symbol potentiometer=c.1

 

symbol val = b0

symbol temp1 = b1             

symbol j = b2

symbol i = b3

symbol indexstep = b4

symbol sequence = b5

 

symbol delay = w7

symbol pausetime=w8

 

let varG = 0   

setint OR 8, 8

 

readadc potentiometer, delay

pausetime=delay*8

Mainprogram:

 

Symbols are defined here.  The index, varG, is set to zero. 

 

The interrupt is enabled by the “setint” command.  The “OR” condition is used with a single pin.  The decimal numeral “8” corresponds to the binary number 00001000.  One of the numerals “8” is the mask, referring to pin C.3, and the other “8” refers to the condition “high” on that pin.

 

“readadc” is the command to read the analog-to-digital-converter at pin C.1, the result of which is placed into the variable “delay”.  The analog value ranges from zero to 4.5 volts; the corresponding digital value ranges from zero to 255.  This maximum digital number is roughly the number of milliseconds in a quarter-second, so if you were to multiply “delay” by eight, the maximum delay would be about two seconds.

 

Here’s how to blank all LED’s:

 

sequence = %00000000

gosub outsequence

       if varG = 1 then

              goto Cell_10_2

       end if

       if varG = 2 then

              goto Cell_10_6

       end if

       if varG = 3 then

              goto Cell_10_10

       end if

       if varG = 4 then

              goto Cell_10_14

       end if

       if varG = 5 then

              goto Cell_10_18

       end if

       if varG = 6 then

              goto Cell_10_22

       end if

       if varG >= 7 then

              goto Cell_7_36

       end if

Index queries.

 

Showing only six possible patterns.  The cell numbers are just default line numbers for the goto commands.

Outsequence subroutine.

 

This subroutine is called each time a sequence of eight bits is required to be sent to the shift register.  The idea is to step each bit of the 8-bit byte into the least significant place and send them in turn down the DATA line to the shift register.  The shift register moves the bits down it’s line into eight temporary registers.

 

“sequence” is the eight-bit byte to illuminate the LED’s.

 

The “for . . . next” loop sends that sequence in series down the “dataline”.

 

The “&%00000001” is a mask which  places only the least significant bit of “val” in the variable “temp1”.

 

“pulsout clockline, 1” clocks the single bytes down the line of temporary registers.

 

Each time the “val = val/2” command is executed in the loop, the bits are shifted down the byte one place to the right.  For example, the decimal number 16 is represented in binary as 00010000.  In order to shift that 1 to the right one place, divide by 2:  16/2 = 8, or in binary, 00001000.

'send sequence to shift register

outsequence:

j=sequence

       val = j

       for i = 1 to 8

              temp1 = val &%00000001

              if temp1 = 1 then high dataline

              else low dataline

              endif

       pulsout clockline,1

       val = val/2

next i

pulsout latch,1

 

return

'pattern 4 x 4

sequence = %11110000

pause pulsetime

gosub outsequence

'pattern 4 x 4

sequence = %00001111

pause pulsetime

gosub outsequence

'pattern 7

sequence = %10000000

pause pausetime

       gosub outsequence

 

sequence = %01000000

pause pausetime

       gosub outsequence

 

sequence = %00100000

pause pausetime

       gosub outsequence

 

sequence = %00010000

pause pausetime

       gosub outsequence

 

sequence = %00001000

pause pausetime

       gosub outsequence

 

sequence = %00000100

pause pausetime

       gosub outsequence

 

sequence = %00000010

pause pausetime

       gosub outsequence

 

sequence = %00000001

pause pausetime

       gosub outsequence

      

Part C, Extension to 16-Bits.

 

In order to extend the project to 16 LED’s we need to make a few changes, but not too many.

 

In the software, we first need to redefine the variables in the “mainprogram” from 8-bit bytes to 16-bit words. 

 

Change all of the sequences to 16-bit words.

 

In the “outsequence” subroutine, change the “for . . . next” loop to 1 through 16.  The mask must be a 16-Bit word, %0000000000000001.

 

In the hardware, connect the first shift register in just the same way as for the 8-bit case with one exception: connect Pin-9, OUPUT, of the first shift register to Pin-14, DATA, of the second shift register.  Additionally, connect Pins 10—13 of the second shift register in parallel with the same pins on the first shift register.  On the second shift register, Pin-9 has no connection.

                     'column 1

{ ;Symbols

symbol varA = b0

symbol varB = b1

symbol varC = b2

symbol varD = b3

symbol varE = b4

symbol varF = b5

symbol varG = b6

symbol varH = b7

symbol varI = b8

symbol varJ = b9

symbol varK = b10

symbol varL = b11

symbol varM = b12

symbol varN = b13

symbol varO = b14

symbol varP = b15

symbol varQ = b16

symbol varR = b17

symbol varS = b18

symbol varT = b19

symbol varU = b20

symbol varV = b21

symbol varTEMPBYTE1 = b22

symbol varTEMPBYTE2 = b23

symbol varTEMPBYTE3 = b24

symbol varTEMPBYTE4 = b25

symbol varTEMPBYTE5 = b26

symbol varTEMPBYTE6 = b27

symbol varTEMPWORD1 = w11

symbol varTEMPWORD2 = w12

symbol varTEMPWORD3 = w13

}

 

main:

 

 

symbol dataline=c.0

symbol clockline=c.4

symbol latch=c.2

symbol switch1=c.3

symbol potentiometer=c.1

 

symbol val = w0

symbol temp1 = w1             

 

symbol j = w2

symbol i = w4

symbol indexstep = w5

symbol sequence = w6

symbol delay = w7

symbol pausetime=w8

symbol k = w9

symbol m = b21

 

'pattern blank

sequence = %0000000000000000  

gosub outsequence

pause 400

       let varG = 0   

       setint OR 8, 8

Cell_7_2:

mainprogram:

readadc potentiometer, delay

pausetime=delay*2

       if varG = 1 then

              goto Cell_10_4

       end if

       if varG = 2 then

              goto Cell_10_8

       end if

       if varG = 3 then

              goto Cell_10_11

       end if

       if varG = 4 then

              goto Cell_10_16

       end if

       if varG = 5 then

              goto Cell_10_20

       end if

       if varG = 6 then

              goto Cell_16_24

       end if

       if varG = 7 then

              goto Cell_10_35

       end if

       if varG = 8 then

              goto Cell_10_41

       end if

       if varG = 9 then

              goto Cell_10_54

       end if

       if varG = 10 then

              goto Cell_10_59

       end if

       if varG = 11 then

              goto Cell_10_77

       end if

       if varG = 12 then

              goto Cell_10_81

       end if

Cell_7_87:

       if varG >= 13 then

              goto Cell_7_89

       end if

       goto Cell_7_2

 

Cell_7_89:

'pattern blank

sequence = %0000000000000000  

j=sequence

       val = j

       for i = 1 to 16

              temp1 = val &%000000000000001

              if temp1 = 1 then high dataline

              else low dataline

              endif

       pulsout clockline,1

       val = val/2

next i

 

pulsout latch,1

 

pause 400

 

 

let varG = 0

 

       goto Cell_7_2

 

Cell_10_81:

'pattern 12

varU = varG

sequence = %0100010001000100

pause pausetime

       gosub prc_outsequence

'pattern 12

sequence = %1000100010001000

pause pausetime

       gosub prc_outsequence

       goto Cell_7_87

 

prc_outsequence:

'send sequence to shift register

 

if varG <> varU then

       goto mainprogram:

endif

j=sequence

       val = j

       for i = 1 to 16

              temp1 = val &%000000000000001

              if temp1 = 1 then high dataline

              else low dataline

              endif

       pulsout clockline,1

       val = val/2

next i

 

pulsout latch,1

 

 

       return

      

Cell_10_77:

'pattern 11

varU = varG

sequence = %0010001000100010

pause pausetime

       gosub prc_outsequence

'pattern 11

sequence = %0001000100010001

pause pausetime

       gosub prc_outsequence

       goto Cell_7_87

 

Cell_10_59:

'pattern 10

varU = varG

sequence = %1111111111111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %0111111111111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1011111111111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1101111111111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1110111111111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111011111111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111101111111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111110111111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111111011111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111111101111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111111110111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111111111011111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111111111101111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111111111110111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111111111111011

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111111111111101

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111111111111110

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111111111111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111111111111110

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111111111111101

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111111111111011

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111111111110111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111111111101111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111111111011111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111111110111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111111101111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111111101111111

pause pausetime

'pattern 10

sequence = %1111111011111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111110111111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111101111111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1111011111111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1110111111111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %1101111111111111

pause pausetime

       gosub prc_outsequence

'pattern 1

sequence = %1011111111111111

pause pausetime

       gosub prc_outsequence

'pattern 10

sequence = %0111111111111111

pause pausetime

       gosub prc_outsequence

       goto Cell_7_87

 

Cell_10_54:

'pattern 9

varU = varG

sequence = %0000000000000000

pause pausetime

       gosub prc_outsequence

'pattern 9

sequence = %1111111111111111

pause pausetime

       gosub prc_outsequence

       goto Cell_7_87

 

Cell_10_41:

'pattern 8

varU = varG

sequence = %0000000110000000

pause pausetime

       gosub prc_outsequence

'pattern 8

sequence = %0000001001000000

pause pausetime

       gosub prc_outsequence

'pattern 8

sequence = %0000010000100000

pause pausetime

       gosub prc_outsequence

'pattern 8

sequence = %0000100000010000

pause pausetime

       gosub prc_outsequence

'pattern 8

sequence = %0001000000001000

pause pausetime

       gosub prc_outsequence

'pattern 8

sequence = %0010000000000100

pause pausetime

       gosub prc_outsequence

'pattern 8

sequence = %0100000000000010

pause pausetime

       gosub prc_outsequence

'pattern 8

sequence = %1000000000000001

pause pausetime

       gosub prc_outsequence

'pattern 8

sequence = %0000000000000000

pause pausetime

       gosub prc_outsequence

'pattern 8

sequence = %1000000000000001

pause pausetime

       gosub prc_outsequence

'pattern 8

sequence = %0100000000000010

pause pausetime

       gosub prc_outsequence

'pattern 8

sequence = %0010000000000100

pause pausetime

       gosub prc_outsequence

'pattern 8

sequence = %0001000000001000

pause pausetime

       gosub prc_outsequence

'pattern 8

sequence = %0000100000010000

pause pausetime

       gosub prc_outsequence

'pattern 8

sequence = %0000010000100000

pause pausetime

       gosub prc_outsequence

'pattern 8

sequence = %0000001001000000

pause pausetime

       gosub prc_outsequence

'pattern 8

sequence = %0000000110000000

pause pausetime

       gosub prc_outsequence

'pattern 8

sequence = %0000000000000000

pause pausetime

       gosub prc_outsequence

       'column 2; append to end of column 1

 

 

'pattern 6

sequence = %1000000000000001

pause pausetime

       gosub prc_outsequence

'pattern 6

sequence = %0100000000000010

pause pausetime

       gosub prc_outsequence

'pattern 6

sequence = %0010000000000100

pause pausetime

       gosub prc_outsequence

'pattern 6

sequence = %0001000000001000

pause pausetime

       gosub prc_outsequence

'pattern 6

sequence = %0000100000010000

pause pausetime

       gosub prc_outsequence

'pattern 6

sequence = %0000010000100000

pause pausetime

       gosub prc_outsequence

'pattern 6

sequence = %0000001001000000

pause pausetime

       gosub prc_outsequence

'pattern 6

sequence = %0000000110000000

pause pausetime

       gosub prc_outsequence

'pattern 6

sequence = %0000000000000000

pause pausetime

       gosub prc_outsequence

'pattern 6

sequence = %0000000110000000

pause pausetime

       gosub prc_outsequence

'pattern 6

sequence = %0000001001000000

pause pausetime

       gosub prc_outsequence

'pattern 6

sequence = %0000010000100000

pause pausetime

       gosub prc_outsequence

'pattern 6

sequence = %0000100000010000

pause pausetime

       gosub prc_outsequence

'pattern 6

sequence = %0001000000001000

pause pausetime

       gosub prc_outsequence

'pattern 6

sequence = %0010000000000100

pause pausetime

       gosub prc_outsequence

'pattern 6

sequence = %0100000000000010

pause pausetime

       gosub prc_outsequence

'pattern 6

sequence = %1000000000000001

pause pausetime

       gosub prc_outsequence

'pattern 6

sequence = %0000000000000000

pause pausetime

       gosub prc_outsequence

       goto Cell_7_87

 

Cell_10_35:

'pattern 7

varU = varG

sequence = %1110011111100111

pause pausetime

       gosub prc_outsequence

'pattern 7

sequence = %0001100000011000

pause pausetime

       gosub prc_outsequence

'pattern 7

sequence = %1110011001100111

pause pausetime

       gosub prc_outsequence

'pattern 7

sequence = %1111111111111111

pause pausetime

       gosub prc_outsequence

'pattern 7

sequence = %0111111001111110

pause pausetime

       gosub prc_outsequence

'pattern 7

sequence = %0011110000111100

pause pausetime

       gosub prc_outsequence

'pattern 7

sequence = %0001100000011000

pause pausetime

       gosub prc_outsequence

'pattern 7

sequence = %0000000000000000

pause pausetime

       gosub prc_outsequence

       goto Cell_7_87

 

Cell_16_24:

'pattern 6

varU = varG

 

sequence = 0

gosub outsequence

pause pausetime

 

sequence = %0000000000000001

gosub outsequence

pause pausetime

 

sequence = 1

for k = 1 to 15

       sequence = sequence * 2

       gosub outsequence

       pause pausetime

next k

 

sequence = 0

gosub outsequence

pause pausetime

 

sequence = 32768

gosub outsequence

pause pausetime

 

for k = 1 to 15

       sequence = sequence/2

       gosub outsequence

       if varG <> 6 then

              gosub mainprogram:

       endif

       pause pausetime

next k

 

pause pausetime

       goto Cell_7_87

 

Cell_10_20:

'pattern 5

varU = varG

sequence = %1000000000000010

pause pausetime

       gosub prc_outsequence

'pattern 5

sequence = %0100000000000001

pause pausetime

       gosub prc_outsequence

       goto Cell_7_87

 

Cell_10_16:

'pattern 4

varU = varG

sequence = %1100110011001100

pause pausetime

       gosub prc_outsequence

'pattern 4

sequence = %0011001100110011

pause pausetime

       gosub prc_outsequence

       goto Cell_7_87

 

Cell_10_11:

'pattern 3

varU = varG

for m = 1 to 5

sequence = %1000000000000000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

sequence = %0000000000000001

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

next m

 

for m = 1 to 5

sequence = %0100000000000000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

sequence = %0000000000000010

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

next m

 

for m = 1 to 5

sequence = %0010000000000000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

sequence = %0000000000000100

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

next m

 

for m = 1 to 5

sequence = %0001000000000000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

sequence = %0000000000001000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

next m

 

for m = 1 to 5

sequence = %0000100000000000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

sequence = %0000000000010000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

next m

      

for m = 1 to 5

sequence = %0000010000000000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

sequence = %0000000000100000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

next m

 

for m = 1 to 5

sequence = %0000001000000000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

sequence = %0000000001000000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

next m

 

for m = 1 to 5

sequence = %0000000100000000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

sequence = %0000000010000000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

next m

 

 

for m = 1 to 5

sequence = %0000000001000000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

sequence = %0000001000000000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

next m

 

for m = 1 to 5

sequence = %0000000000100000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

sequence = %0000010000000000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

next m

 

for m = 1 to 5

sequence = %0000000000010000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

sequence = %0000100000000000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

next m

 

for m = 1 to 5

sequence = %0000000000001000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

sequence = %0001000000000000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

next m

 

for m = 1 to 5

sequence = %0000000000000100

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

sequence = %0010000000000000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

next m

 

for m = 1 to 5

sequence = %0000000000000010

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

sequence = %0100000000000000

pause pausetime

       if varG <> varU then

       goto mainprogram:

       end if

gosub outsequence

next m

 

 

sequence = %0000000000000000

pause pausetime

pause pausetime

gosub outsequence

 

       goto Cell_7_87

 

Cell_10_8:

'pattern 2

varU = varG

sequence = %1111000011110000

pause pausetime

       gosub prc_outsequence

'pattern 2

sequence = %0000111100001111

pause pausetime

       gosub prc_outsequence

       goto Cell_7_87

 

Cell_10_4:

'pattern 1

varU = varG

sequence = %1000000110000001

pause pausetime

       gosub prc_outsequence

'pattern 1

sequence = %1100001111000011

pause pausetime

       gosub prc_outsequence

'pattern 1

sequence = %1110011111100111

pause pausetime

       gosub prc_outsequence

'pattern 1

sequence = %1111111111111111

pause pausetime

       gosub prc_outsequence

'pattern 1

sequence = %0111111001111110

pause pausetime

       gosub prc_outsequence

'pattern 1

sequence = %0011110000111100

pause pausetime

       gosub prc_outsequence

'pattern 1

sequence = %0001100000011000

pause pausetime

       gosub prc_outsequence

'pattern 1

sequence = %0000000000000000

pause pausetime

       gosub prc_outsequence

       goto Cell_7_87

 

interrupt:

Cell_1_11:

       if pinC.3=1 then

 

              goto Cell_1_13

       end if

       goto Cell_1_11

 

Cell_1_13:

       if pinC.3=0 then

 

              goto Cell_1_15

       end if

       goto Cell_1_13

 

Cell_1_15:

       inc varG

       setint OR 8, 8

       return

 

#no_data     'reduce download time

 

              'end of program

Program for 16-Bit LED display with 11 patterns.

 

This is a complete program to operate the 16-Bit project.  Copy and paste the second column onto the end of the first column.

 

This program works well; if any variables clash, they don’t seem to show in it the final result.

 

All redundancies, mistakes, errors, etc., etc. the responsibility of the user to find, troubleshoot, correct, etc., etc.

Copy and paste this subroutine into your program; it works.  This subroutine was found on the internet.  The original: 

 

 

74HC595 Shift Register and PICAXE 18M2 Microcontroller

 

by Lewis Loflin

 

http://www.bristolwatch.com/picaxe/74hc565_demo.htm