Compareison of two numbers in Pbasic
Cogburn
Posts: 62
I want to compare two values returned from RCTime for two photoresistors.. If these values are within 10 % of each other, I want the stamp to execute a loop to read RCTime again. If the value collected from the left photoresistor is 10% or more higher than the value collected for the right photoresistor, I want a stepper motor to move to the left by a small increment. If the value for the right photoresistor is more than 10% higher than the left one, I want the stepper motor to move to the right by a small increment. I have the stepper moving left and right at my command. I have the photoresistors reading values that I can compare but I can't figure out how to let Pbasic make the comparison. Any ideas?
Comments
There are other ways to skin the cat, for example the 10% rule can be done with this formula
IF RCTL >= RCTR */ 282 THEN ' means, RCTL 10% larger than RCTR, look up the */ operator
Here is another way using the SELECT:CASE command and the */282 for 110% and */230 for 90%:
Or, another way using the LOOKDOWN command. For this one you have to create a dummy subroutine "do_nothing" that just RETURNs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com