Shop OBEX P1 Docs P2 Docs Learn Events
basic stamp, shift registers, memsic sensor, need assistance with code revision — Parallax Forums

basic stamp, shift registers, memsic sensor, need assistance with code revision

lighting ladylighting lady Posts: 7
edited 2009-12-30 01:25 in BASIC Stamp
I have created a project where a memsic sensor triggers four shift registers which have 8 LEDs attached to each shift register. thirty two LEDs in total.
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

  • $WMc%$WMc% Posts: 1,884
    edited 2009-12-30 01:25
    Try dropping this off

    Clock4 PIN 9
    SerData4 PIN 10
    Latch4 PIN 11

    SHIFTOUT SerData4, Clock4, MSBFIRST, [noparse][[/noparse]pattern]

    The last "IF" may need to go too

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············___$WMc%___···························· BoogerWoods, FL. USA
Sign In or Register to comment.