Shop OBEX P1 Docs P2 Docs Learn Events
74hc595 shift register — Parallax Forums

74hc595 shift register

dr_eggman198dr_eggman198 Posts: 15
edited 2005-07-04 19:57 in BASIC Stamp
so, If you have a 74hc595 shift register to increase the number of i/o pins, do you treat them as you would a normal i/o pin in the programming. like, you would assign the first pin of the 74hc595 to a variable, a1, and then use a1 in the program like you would use a pin on the basic stamp?

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-04 19:56
    Sort of.· The 74HC595 is an output device -- you get eight.· You could create a byte variable to support the pins on the '595 and then alias them, either in the definitions or using the BITx modifier of the variable.· Let's say you have eight LEDs connected to an '585 and you want to light just the LED connected to output A (LSB).

    leds··· VAR··· Byte
    alarm·· VAR··· leds.BIT7

    Main:
    · leds = %00000001········' turn on output A
    · GOSUB Update_Leds
    · PAUSE 500
    · leds.BIT1 = 1···········' now turn on output B (A still on)
    · GOSUB Update_Leds
    · leds =·%00000000······· ' clear leds
    · alarm = 1·············· ' turn on alarm LED (output H)
    · GOSUB Update_Leds
    · END

    Update_Leds:
    · SHIFTOUT Dpin, Clk, MSBFIRST, [noparse][[/noparse]leds]
    · PULSOUT Latch, 3
    · RETURN

    See the BASIC Stamp help file under SHIFTOUT for the circuit details.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-07-04 19:57
    Hello,

    ·· No, the pins on the 74HC595 would be stored in a single BYTE variable if you were using one '595, and that variable would be SHIFTED out to the '595 using the SHIFTOUT command.· This would place the value in the BYTE variable (8 bits) on the 8 output lines.



    EDIT: Jon beat me, but there's a second analogy...· =)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.