Comparing multiple inputs

higgeh

New Member
Im kind of new here so i hope someone can help

Im working on an ultrasound scanning device that will rotate around 180 degrees then point a servo at where the nearest object is.

The problem im having is i have 4 variables stored with a figure between 0 and 255 and i would like a bit of program that basically tells me which variable is the lowest


any ideas?
 

Technical

Technical Support
Staff member
Four variables b0 -b3.
Code:
symbol result = b10 ' actual lowest value
symbol result_pointer = b11 '0,1,2 or 3 
 
result = b0
result_pointer = 0
 
if b1 < result then
result = b1
result_pointer = 1
end if
 
if b2 < result then
result = b2
result_pointer = 2
end if
 
if b3 < result then
result = b3
result_pointer = 3
end if
 

higgeh

New Member
thank you works a total treat

if anyone would like the code for the scanning ultrasound let me know i think its about finished but a bit messy
 

Dippy

Moderator
Well done. Just tidy it up and post it in the finished projects section. Then people can view it, admire it and pinch it for their school projects :)

A biref and nicely written description is good too.

I'm never sure whether to comment programmes here. On one hand it's darned helpful. On the other, if it does get c'n'p'd for school homework the lazy student won't be able to explaint to teacher how it works....
 

Rickharris

Senior Member
Well done. Just tidy it up and post it in the finished projects section. Then people can view it, admire it and pinch it for their school projects :)

A biref and nicely written description is good too.

I'm never sure whether to comment programmes here. On one hand it's darned helpful. On the other, if it does get c'n'p'd for school homework the lazy student won't be able to explaint to teacher how it works....
Don't worry neither will the teacher be able to explain in many cases!
 

higgeh

New Member
my teacher used to hate me for that

we were asked to make an alarm system for an exam.

3 inputs
on/off switch (1)
pressure pad (2)
reed switch (3)

so basically 1.(2+3)

two gates simple

well i sussed this out within about 10 mins of a 1hr30min exam

ended up with about 6 gates a reset switch and some tamper proof sensors.

Funny i got a credit for that
 
Top