Code
Hi my program is not completely executing my exact instruction set. I want it to check two sensors and if the difference of the two sensors is greater than a certain constant assigned then make the move instructed. My code attached only compares the sensor and whenever there is a slight difference it execute. :
bs2
![](/plugins/FileUpload/images/file.png)
6K
Comments
It looks like the values you are shifting to the ADC have been changed from the original program; which is what sets the mode and channel you are reading in. For example, if you are want to read Channel 0 in a single ended mode, you could use the following:
· LOW CS
· SHIFTOUT DataIn, Clock, MSBFIRST, [noparse][[/noparse]%11000\5 ]···· ' Select CH0, Single-Ended
· SHIFTIN DataOut, Clock, MSBPOST, [noparse][[/noparse]result0\13]·· ' Read ADC
· HIGH CS
From there, you could change the last two bits accordingly to select the channel you would like. In the datesheet there is a truth table that will explain how to use this function; so you can make sure you have the proper channels selected to get the inforamtion from?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com
There are at least two problems with this. For one, you're using "&" which is a bit-wise AND operation when what you need to use is "AND" which is a logical test. Look in the BASIC Stamp Syntax and Reference Manual for a more detailed description of these operators. You can also look in the help files of the Stamp Editor.
The 2nd problem is that you're testing for equality between X1 - X0 and V. Is that really what you want?
I think what you want is: IF ABS(X1 - X0) > 400 THEN