Mini Maestro output

Hi

I am new at Pololu Mini Maestro.
I want to using a switch control a servo and put 2 outputs high.
I use the following script which worksfine for me

# Set the servo to 4000, 6000, or 8000 depending on an analog input.
begin
0 get_position # get the value of the pot, 0-1023
dup 300 less_than
if
4000 # go to 4000 for values 0-299
else
dup 600 less_than
if
6000 # go to 6000 for values 300-599
else
8000 # go to 8000 for values 600-1023
endif
endif
1 servo
drop
repeat

What I would like to know is how do I put the outputs 2 and 3 high when the switch is on?

Hello.

Once you have pins 2 and 3 configured as outputs in the Channel Settings tab, you can use the SERVO command to control if the output is high or low. When you set the target of an output channel to 1500μs or higher, it will be high, otherwise it will be low.

If you try modifying your script to add this and run into problems, I would be glad to give you more specific advice; however, it is not clear to me if you want your current switch to also toggle the output pins or if you want to add a new switch that controls those pins. Also, your current script has 3 ranges for your switch (0-299, 300-599, 600-1023), and it is not clear to me which of those ranges you would want to turn on the output pins. If you could clarify those things, I can offer more specific suggestions.

Brandon

Hi Brandon

Thank you for your answer.
In the meantime I could make some changes to the script and it is running ok.

What I wanted was to use one switch to control one servo in two positions and 2 outputs and the outputs become high when the servo was in one of the positions .

I include the changed script so you can comment.

begin
0 get_position # get the value of the pot, 0-1023
dup 400 less_than
if
4000 1 servo # go to 4000 for values 0-299
6000 2 servo
6000 3 servo
else
8000 1 servo # go to 8000 for values 600-1023
4000 2 servo
4000 3 servo
#endif
endif
drop
repeat

Sacramento

That script seems like it should work how you described. When the input on channel 0 is low, the servo goes to 1000μs and the two outputs are driven high, otherwise, the servo goes to 2000μs and the outputs are driven low.

Is it behaving how you want?

Brandon

Hi,

Yes it is behaving the way I want.
Maybe the script can be of use for others.
Thanks for your cooperation

Sacramento

1 Like