Hello,
I am brand new to coding and was hoping someone could help me. I am using a Mini Maestro 12. I would like to use multiple potentiometers to control multiple pwm outputs using hysteresis. Is it even possible for the Mini Maestro 12 to operate four channels that way? I have successfully followed the servo controller user guide provided by Pololu to use one potentiometer to control one output. I understand how to wire my pots, how to select the correct mode in the channel settings, and where in the code to select the source and where to select the pwm output. The trouble I am running into is knowing where to do what when adding additional channels to the script. My errors are usually related to not closing begin/repeat loops, or the section of code that I add does not run at all. If someone could write the code as a reply that would be the most helpful to me. Below I have copied the script from the user guide and added some additional questions in bold. Thanks.
Do I need to add a new servo range for each new channel or can I use this for all additional channels?
begin
4000 0 300 servo_range
6000 300 600 servo_range
8000 600 1023 servo_range
repeat
Do I need a seperate servo_range sub routine, if so where does it go?
sub servo_range
pot 2 pick less_than logical_not # >= low
pot 2 pick greater_than logical_not # <= high
logical_and
if
I would like to control a switch as well, does this code fit inside the begin and repeat section just below this or does it go some where else?
2 get_position
dup 200 greater_than
if
6100
else
8000
endif
8 servo
drop
begin
pot 2 pick 10 minus less_than logical_not # >= low - 10
pot 2 pick 10 plus greater_than logical_not # <= high + 10
logical_and
while
2 pick 0 servo
repeat
endif
drop drop drop
return
Why is this sub routine outside the repeat command? Could it be placed at the top of the script?
sub pot
1 get_position
return