Shop OBEX P1 Docs P2 Docs Learn Events
need code for 4 dip sitches to use case comand — Parallax Forums

need code for 4 dip sitches to use case comand

NauketecNauketec Posts: 51
edited 2008-07-25 02:37 in BASIC Stamp
I am new to basic stamp coding. Looking for code for the BS402P that uses the case comand to read 4 DIP switches that·when on go to ground·(on ports P10 to P13)to jump to different sections in the program called "mode 0" "mode 1" "mode 2" and so on to mode 15.· Thanks for any help but please be detailed for I am a beginner.· Daniel

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-25 02:37
    Unfortunately, you haven't picked I/O pins that occur as a group of 4. That would make things easier because you could use the INA/INB/INC/IND special names to refer to all 4 input pins as a single value. You can still use an expression like "(INS >> 10) & $F" to get the value of I/O pins 10-13 as a numeric value from 0 to 15. If, for some reason, you want the switches to work backwards (from pin 13 to 10), use the REV operator (there's a description in the Stamp Reference Manual). Once you have that value, use the case statement as described in the Manual to select from 16 groups of statement. Another option is to use the ON ... GOTO statement to select from a list of 16 labels. Again, check the Manual for a description and examples.
Sign In or Register to comment.