Shop OBEX P1 Docs P2 Docs Learn Events
Expanding inputs, using shiftin — Parallax Forums

Expanding inputs, using shiftin

TonyATonyA Posts: 226
edited 2006-05-31 16:16 in BASIC Stamp
Hi,

I'm just learning about using shiftin. Would it be possible to shiftin 12 bits and assign each bit a separate variable?

shiftin datapin, clockpin, mode, [noparse][[/noparse]var1\1, var2\1, var3\1, ... var12\1]

I am using a shift register that will send out the state of 12 switches to the stamp. I need to read the state of each individual switch. var1 is the variable for the state of the 1st switch, etc. I am putting one bit in each variable.

Do I have this right?

Thanks for any help.
TonyA

Comments

  • Tracy AllenTracy Allen Posts: 6,658
    edited 2006-05-31 16:06
    You could do that, but it is easier to use the Stamp's aliasing for variable names:

    switches  VAR Word
    
    sw0 VAR switches.bit0
    sw1 VAR switches.bit1
    sw2 VAR switches.bit2
    sw3 VAR switches.bit3
    sw4 VAR switches.bit4
    sw5 VAR switches.bit5
    sw6 VAR switches.bit6
    sw7 VAR switches.bit7
    sw8 VAR switches.bit8
    sw9 VAR switches.bit9
    sw10 VAR switches.bi10
    sw11 VAR switches.bit11
    
    shiftin datapin, clockpin, mode, [noparse][[/noparse]switches\12]
    IF sw5 THEN DEBUG "5 closed",cr
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • TonyATonyA Posts: 226
    edited 2006-05-31 16:16
    I see, Thanks for the help.
Sign In or Register to comment.