PDA

View Full Version : Thanks to tracy and mike for their quality help



tedroberson
03-10-2010, 10:42 AM
The inputs provide the three 0 or 1 bits that you need, but it is convenient to assemble them into one NIBble for the subsequent program. That NIBble should be
%cba0http://forums.parallax.com/images/smilies/yeah.gif
where a is the bit from IN4, b is from IN3 and c is from IN6. A multiplication by 2 or 4 moves the associated bit one or two places to the left in the binary representation. So %0001 * 2 = %0010 and %0001 * 4 = %0100. The final <<1 is the same as *2. It moves the three bits one place to the left. So, %0cba becomes %cba0.

All that permutation would have been avoided if you had chosen 3 neighboring pins for the INputs.

I'm very happy that the code worked for you.
Help problem with line of code
Originally Sent : 3/7/2010 11:01:26 PM GMT by tedroberson said...

Tracy,your program solved my problems but the followering line of code I can't figure out

x = IN4 + (IN3*2) + (IN6*4) << 1.

Looks like you're adding multiplying and shifting bits left.

Please tell me why (in3 is * 2 ) and ( in6 is * by 4).

Thanks, Ted Roberson

Thanks Tracy·for your quality answers.

Tracy Allen
03-10-2010, 12:31 PM
Thanks Ted, I appreciate the comment. I think you are referring back to your earlier thread, http://forums.parallax.com/showthread.php?p=884813 and PM followup.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)