Comparing values in an array...
Matt White
Posts: 60
I'm using an ADC0834 to process analog·readings from 4 Sharp GP2D12 sensors.· All that works fine.· I have an array called adc(0,1,2, ...).· Essentially what I want to do is evaluate the four sensor readings stored in the array and find out which one has the largest value.· While this seems like an easy task when I start coding it, the excersize turns into a lots and lots of IF, THEN, ELSE statements... Anyone got a better way to do this?·
Would I be better off just checking each value against a set of threasholds?· The application is colision avoidance -- I'd also like to know "how far" I am from an object, wall, etc.· The idea being the closer I am to an obstacle the more of a course correction I need to make.
Thanks!
Matt
·
Would I be better off just checking each value against a set of threasholds?· The application is colision avoidance -- I'd also like to know "how far" I am from an object, wall, etc.· The idea being the closer I am to an obstacle the more of a course correction I need to make.
Thanks!
Matt
·
Comments
The testing in the loop can be more complex as long as all items are treated alike.