Script help needed for Maestro servo controller

Hello there
My name is Aman and I am new to scripts. Here is my problem. I have Pololu servo controller (18Ch). I am trying to sense colors of an object using LED as sensor. Channel 0-3 of servo controller has four different color LEDs attached. I can see sensing of all four LED in maestro controller ranging from 0-100. Now I want to use some math in it like ratio of value of
ch-3/ch-0
ch-3/ch-1
ch-3/ch-2
in if statements to trigger relay using channel 5. I will really appreciate if anyone rectify my script make it working one. Thanks in advance.

Aman

begin
0 get_position
1 get_position
2 get_position
3 get_position

a EQUALS 3 get_position DIVIDE 0 get_position
b EQUALS 3 get_position DIVIDE 1 get_position
b EQUALS 3 get_position DIVIDE 2 get_position
dup a EQUALS 3 more than LOGICAL_AND b EQUALS 4 more than
if
8000
else 
5000
endif
5 servo
repeat

Hello, Aman.

It looks like you are using the mathematical commands incorrectly. The mathematical commands like divide and logical_and take two arguments from the top of the stack, then return a single value as a result. For example, to compute 1 / 2, you write “1 2 divide”. If you want to divide the analog voltage value read on channel 3 by the value on channel 0, then you would write

As another example, if I wanted to know if the ratio of ch-3/ch-0 was greater than a value of 50, I would type:

-Jon