Shop OBEX P1 Docs P2 Docs Learn Events
Help with comparing two 4-character variables one character at a time. attn: J — Parallax Forums

Help with comparing two 4-character variables one character at a time. attn: J

PrestigeWorldPrestigeWorld Posts: 7
edited 2010-03-17 19:16 in BASIC Stamp
We are having a problem with first collecting data from an array of pushbutton switches. We would like to check pins 11-15 for a high signal. When four high signals have been recieved we would like to store the order in which they were recieved. Each pin is assigned a letter value. We would like to compare the user's four letter combo with a specified "correct" four letter combo. We are having some trouble with getting the code to compile. Please take a look. Any suggestions are greatly appreciated.

Thanks,

Prestige Worldwide

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-17 19:16
    For a start, you can't have a 4-character variable.· The Stamps are 16-bit microcontrollers and 4 characters requires 32-bits.· You can either use two words (2 x 16-bits = 4 characters) or you can limit the number of possible letters to 16 and use 4 x 4-bit "nibbles" for the 4 values.· You'd have to translate the 0-15 values to the letters you want for display or just use hexadecimal for this since the Stamp has built-in handling of hexadecimal values.· Since you're using 5 pins, that would work for using "A" through "F" which fits in with hexadecimal.

    Pin 11 would be $A.· Pin 12 would be $B and so on to pin 15 which would be $F.· You could store combinations like $ABEF and compare them in one operation.
Sign In or Register to comment.