I’m trying to write a script for my micro maestro with very little programming knowledge. Right now I simply want to know how to use the “and” function. Basically I want:
If servo 2 is less than 6364 and greater than 5568 then do something. Here’s the code I’ve tried:
# Check if in neutral zone and if so go back to main loop
However every time I try to apply this script I get the 0x0040 error code of Stack overflow/underflow. Can anyone point me in the right direction?
It looks like you are really close to having it working correctly. The main thing is that the value you are reading from channel 2 with
2 get_position is being consumed (i.e. used and taken off the stack) when you do the
To fix it, you can duplicate the measured value by putting a
2 get_position, then, to make sure the
greater_than comparison gets the correct values, you will need to add a
swap command just before
5568 greater_than. For example:
By the way, if you aren’t already using the “Step Script” button to troubleshoot by stepping through the script one step at a time, I highly recommend using it. It is very helpful to be able to monitor the values on the stack (to the right of the script) when diagnosing problems.
Thank you! Thank you! Thank you!
That was exactly what I needed and now my servo is doing exactly what we need!
Really appreciate the help. Have a great day!