Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

Pausing Maestro script

#1

Hi, My question is along these lines. I’m using an Arduino Nano and MiniMaestro12 Servo Controller communicating via serial. What I want to do is “pause” and “play” the servo sequence. I have hardwired the push buttons “pause” and “play”. Is there anyway to do this? I believe stopScript() stops the entire script and it loses track of the frame.

Thank you

Mini maestro start/stop button for sequence
#2

I have a while loop like this in my code. I have a problem though, it acts like a delay where I can’t do anything else. Is there anyway around this? I tried an If statement and that didn’t work… I want it to delay for an interval so I’m using the millis() function. (I’m controlling the Maestro with Arduino Nano.)
The servo sequence is named “highlander”. The other issue I’m having is that I have hardwired two buttons “pause” and “play”. So, in the middle of the “highlander” sequence I want to be able to push the “pause” button to pause the sequence. Also, push the “play” button to play where the sequence left off. Is this possible?

Here is the part of my code that goes wrong:

#include <PololuMaestro.h>
SoftwareSerial maestroSerial(0, 1); // RX, TX


unsigned long time_since_last_reset = 0;

int interval_two = 6000;
MiniMaestro maestro(maestroSerial);
#define highlander 0


void loop () {  

  time_since_last_reset = millis();

  while((millis() - time_since_last_reset) < interval_two){   
    maestro.restartScript(highlander);
  } 


  valB = digitalRead(inPinB);     //button to pause
  valC = digitalRead(inPinC);    //button to "continue playing"
 
 if (valB == LOW) {
  maestro.stopScript(); // does this pause the sequence at a frame or stop the code all together?
 }
 
 if (valC == LOW) {
  //play servo seq. where it left off. What is the code?
 }
}
How would i trigger a sequence with a button (mini maestro 12)
#3

Hello.

I created a new topic and moved both your posts here, since they seem to be about the same issue.

Do you have the buttons connected to your Arduino or Maestro? The Maestro does not have a command to pause a running script immediately like you described. If you want to pause your servo movements by pressing (and releasing) a “pause” button, you are probably going to have to use your Arduino to read from the buttons and control the servo movements instead of using the Maestro’s script. You might consider this alternative method of “pausing” the Maestro script in your system.

- Amanda