View Full Version : Help with comparing two 4-character variables one character at a time. attn: J
03-18-2010, 01:17 AM
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.
03-18-2010, 02:16 AM
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.