No Subject
I have created a project where a memsic sensor triggers four shift registers which have 8 LEDs attached to each shift register.
By using the shift register I was able to increase the quantity of LEDs for the project.
The code below was used with four shift registers. I have tried changing the code to use with three shift registers because that was the quantity
of LEDs that I wanted to use. I first started with changing the code to the last pin being 8. In short nothing I did worked. I am not familiar with code
which is why I could use some assistance of how to alter the code using three shift registers rather than four shift registers.
Thanks for your help.
ML5744
' {$STAMP BS2}
' {$PBASIC 2.5}
Clock PIN 0
SerData PIN 1
Latch PIN 2
Clock2 PIN 3
SerData2 PIN 4
Latch2 PIN 5
Clock3 PIN 6
SerData3 PIN 7
Latch3 PIN 8
Clock4 PIN 9
SerData4 PIN 10
Latch4 PIN 11
Delaytime CON 100
pattern VAR BYTE
x VAR WORD
y VAR WORD
Reset:
LOW Latch
pattern = %00000001
Main:
DO
GOSUB Out_595
PAUSE DelayTime
pattern = pattern << 1
LOOP UNTIL (pattern = %10000000)
DO
GOSUB Out_595
PAUSE Delaytime
pattern = pattern >> 1
LOOP UNTIL (pattern = %00000001)
GOTO main
Out_595:
SHIFTOUT SerData, Clock, MSBFIRST, [noparse][[/noparse]pattern]
SHIFTOUT SerData2, Clock2, MSBFIRST, [noparse][[/noparse]pattern]
SHIFTOUT SerData3, Clock3, MSBFIRST, [noparse][[/noparse]pattern]
SHIFTOUT SerData4, Clock4, MSBFIRST, [noparse][[/noparse]pattern]
PULSIN 14, 1, x
PULSIN 15, 1, y
IF x < 2300 THEN PULSOUT Latch, 5
IF x > 2800 THEN PULSOUT Latch2, 5
IF y < 2300 THEN PULSOUT Latch3, 5
IF Y > 2800 THEN PULSOUT Latch4, 5
RETURN
END
By using the shift register I was able to increase the quantity of LEDs for the project.
The code below was used with four shift registers. I have tried changing the code to use with three shift registers because that was the quantity
of LEDs that I wanted to use. I first started with changing the code to the last pin being 8. In short nothing I did worked. I am not familiar with code
which is why I could use some assistance of how to alter the code using three shift registers rather than four shift registers.
Thanks for your help.
ML5744
' {$STAMP BS2}
' {$PBASIC 2.5}
Clock PIN 0
SerData PIN 1
Latch PIN 2
Clock2 PIN 3
SerData2 PIN 4
Latch2 PIN 5
Clock3 PIN 6
SerData3 PIN 7
Latch3 PIN 8
Clock4 PIN 9
SerData4 PIN 10
Latch4 PIN 11
Delaytime CON 100
pattern VAR BYTE
x VAR WORD
y VAR WORD
Reset:
LOW Latch
pattern = %00000001
Main:
DO
GOSUB Out_595
PAUSE DelayTime
pattern = pattern << 1
LOOP UNTIL (pattern = %10000000)
DO
GOSUB Out_595
PAUSE Delaytime
pattern = pattern >> 1
LOOP UNTIL (pattern = %00000001)
GOTO main
Out_595:
SHIFTOUT SerData, Clock, MSBFIRST, [noparse][[/noparse]pattern]
SHIFTOUT SerData2, Clock2, MSBFIRST, [noparse][[/noparse]pattern]
SHIFTOUT SerData3, Clock3, MSBFIRST, [noparse][[/noparse]pattern]
SHIFTOUT SerData4, Clock4, MSBFIRST, [noparse][[/noparse]pattern]
PULSIN 14, 1, x
PULSIN 15, 1, y
IF x < 2300 THEN PULSOUT Latch, 5
IF x > 2800 THEN PULSOUT Latch2, 5
IF y < 2300 THEN PULSOUT Latch3, 5
IF Y > 2800 THEN PULSOUT Latch4, 5
RETURN
END
Comments
Saying "nothing I did worked" doesn't help us help you. Describe what you did and what happened.
Please remember that these forums don't work very well when you give little information and expect others to write your code for you. They're for asking questions, the more specific the better, and getting answers to those questions. The more information you provide, the better the quality of the answer.