How to reset micro maestro via arduino sketch

Hi
Please excuse if this is a somewhat simple question, but I have read and searched extensively looking at what, will no doubt be, a very simple solution.
I have a micro maestro running a simple internal script that is controlled by an arduino uno via serial commands with various info displayed on an lcd.
I have included the pololumaestro library in the arduino sketch and all is working as it should.
I now would like to be able to reset the maestro via the arduino sketch.
The reset pin on the maestro is wired as it needs to be to channel #5 and the maestro will reset when this pin is either taken to ground via a button or in the pololu maestro software.

The pololumaestro library has this to say about the ‘reset’ function…

 void Maestro::reset  (  )  
 Resets the Maestro by toggling the resetPin, if a resetPin was given. 
 By default this function will do nothing. If the resetPin was specified while constructing the Maestro object, it will toggle that   pin.         
 That pin needs to be wired to the Maestro's RST pin for it to reset the servo controller. 

So… how to I ‘specify’ the resetPin is channel 5 on the maestro???
I know it is a simple thing, and I realise im showing by ignorance of the arduino sketch language… but please help.

Here is my sketch as it stands…

[code]
#include <PololuMaestro.h>
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // select the pins used on the LCD panel
SoftwareSerial maestroSerial(2, 3); // RX, TX

// define some values used by the panel and buttons
int lcd_key = 0;
int adc_key_in = 0;

#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define btnNONE 5

int scriptStatus = 0; // variable for reading if the maestro script is running
int servoPosition = 0; // variable for reading servo position

int read_LCD_buttons(){ // read the buttons
adc_key_in = analogRead(0); // read the value from the sensor

if (adc_key_in > 1000) return btnNONE; 
if (adc_key_in < 50)   return btnRIGHT;  
if (adc_key_in < 250)  return btnUP; 
if (adc_key_in < 450)  return btnDOWN; 
if (adc_key_in < 650)  return btnLEFT; 
if (adc_key_in < 850)  return btnSELECT; 

return btnNONE;                // when all others fail, return this.

}

// create a Maestro object using the serial port.
MicroMaestro maestro(maestroSerial);
maestro.resetPin = 5;

void setup(){

lcd.begin(16, 2); // start the library
lcd.setCursor(0,0); // set the LCD cursor position
lcd.print(" STC BloodRig “); // print a simple message on the LCD
delay(2000);
lcd.setCursor(0,1);
lcd.print(” CONNECTING ");
delay(2000);
lcd.clear();

// Set the serial baud rate.
maestroSerial.begin(9600);
Serial.begin(9600);
delay(1000);

}

void loop(){

scriptStatus = maestro.getScriptStatus();
if (scriptStatus == 0){
lcd.setCursor(0,0);
lcd.print(" STC BloodRig “);
}else{
lcd.setCursor(0,0);
lcd.print(“BloodRig STOPPED”);
lcd.setCursor(0,1);
lcd.print(” Please RESET ");
}

servoPosition = maestro.getPosition(2);
if (servoPosition >= 6000){
lcd.setCursor(0,1);
lcd.print("---- READY -----");
delay(100);
}

servoPosition = maestro.getPosition(3);
if (servoPosition >= 6000){
lcd.setCursor(0,1);
lcd.print("---- ARMED -----");
delay(100);
}

servoPosition = maestro.getPosition(4);
if (servoPosition >= 6000){
lcd.setCursor(0,1);
lcd.print("— BLEEDING —");
delay(100);
}

lcd.setCursor(1,1); // move to the begining of the second line
lcd_key = read_LCD_buttons(); // read the buttons

switch (lcd_key){ // depending on which button was pushed, we perform an action

   case btnRIGHT:{          
        maestro.restartScript(0);
        break;
   }
   case btnLEFT:{
         maestro.restartScript(0); 
         break;
   }    
   case btnUP:{
         servoPosition = maestro.getPosition(3);
         if (servoPosition >= 6000){
           delay(100);
           maestro.restartScript(2);
         }
         break;
   }
   case btnDOWN:{
         servoPosition = maestro.getPosition(2);
         if (servoPosition >= 6000){
           delay(100);
           maestro.restartScript(1);
         }
         break;
   }
   case btnSELECT:{
         maestro.reset();
         
         break;
   }
   /*case btnNONE:{
         lcd.print("NONE  ");  //  No action  will show "None" on the screen
         break;
   }*/

}
}[/code]

Hello.

It sounds like you do not understand how the pololumaestro library works. You cannot set the resetPin to be a channel pin on your Maestro. The library specifically works with an Arduino-compatible board’s I/O pins; not the with the Maestro’s pins. To reset your Maestro from your Arduino through your sketch, you need to connect one of the I/O pins on your Uno to the Maestro’s RST pin. Then pass the resetPin number as a second argument to the Maestro’s constructor. For example, if pin 4 on the Arduino Uno is connected to the Maestro’s RST pin:

MicroMaestro maestro(maestroSerial, 4);	// resetPin = 4

- Amanda

Thanks Amanda, you called me out.
I really don’t fully understand the arduino lauguage yet… But I’m working on it.

Your answer does makes sense … I have re-read the library and now see what it means to add a second argument to specify the resetPin… and the third argument, if added, would specify the device number and so on…

My error was assuming the maestro would be sent a serial command to reset, as all the other commands are… Also explains why I could not find any reference to a ‘reset’ serial command in the maestro documents… There is no such thing!

I will do as you suggest and get the project up and running, but ultimately I wish to control the maestro over an Xbee link.

I think I should be able to achieve this by utilising a serial link via a pair of xbee’s and utilising one of the direct I/O linepassing pins on the xbee’s to pass the resetPin command.
Will let you know how it goes.

Thanks for your help!