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]