Hi All,
It’s my first time using the Mini Maestro with an Arduino Mega and I get a slow yellow flashing light from the Maestro when I connect it up.
I’m trying to implement the second example at darrenfeetham.com/18ssc.html however I have made a few modifications to the code:
- I’ve changed “NewSoftSerial” to “SoftwareSerial” as this is the new library
- I’ve tried the code with pins 0/1, 3/4 and 10/11 for RX/TX
- I’ve tried with mySerial.print and mySerial.write (although I still don’t quite get the difference here)
The wiring is the same as in the example, with the exception that the Arduino is being powered from USB. Given the changes I’m not sure if the problem is with the code or the Maestro. From the manual the yellow light seems to indicate the RST has been set low - however the pin isn’t linked in and I presume I don’t have to drive it high each time?
A few notes:
- The batteries are currently providing just over 6V to the servo power input on the Maestro
- I have checked servo indexing
My code is below.
Thanks for your help everyone
Cerb
// Board: Arduino Duemilanove
// Title: Ard_MiniM_2S
// Date: 24/02/12
// Auther: By Darren Feetham
// Website: www.darrenfeetham.com
// Details: This is a scetch connecting Arduino and
// the Mini Maestro Serial Servo Controller.
// 18SSC-------------------// 18 Serial Servo Controller
// Power 6v Seperate power supply than Arduino
// GND to GND on the Arduino
// SSC RX pin to Arduino TX pin Pin04
// SSC TX pin to Arduino RX pin Pin03
// LIBRARIES---------------// Included libraries
// NewSoftSerial
#include <SoftwareSerial.h>
// ^^^---------------------//
// DEFINE------------------// Define constants
// Serial pins
#define txPin 4
#define rxPin 3
// ^^^---------------------//
// INITUALIZE--------------// initalizing pins and bytes etc
// ?
SoftwareSerial mySerial(rxPin, txPin);
// ^^^---------------------//
// SETUP-------------------// setup before we go
void setup() // run once, when the sketch starts
{
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
mySerial.begin(9600);
// while(!Serial);
// delay(1000);
}
// LOOP--------------------// The base for the program
void loop()
{
delay(1000);
set_target(0, 8000);
delay(1000);
set_target(1, 4000);
delay(1000);
set_target(0, 6000);
delay(1000);
set_target(1, 6000);
delay(1000);
set_target(0, 4000);
delay(1000);
set_target(1, 8000);
}
// ^^^---------------------//
// Send a Set Target command to the Maestro.
// Target is in units of quarter microseconds
// so the normal range is 4000 to 8000.
void set_target(unsigned char servo, unsigned int target)
{
mySerial.print(0xAA); //start byte
mySerial.print(0x0C); //device id
mySerial.print(0x04); //command number
mySerial.print(servo); //servo number
mySerial.print(target & 0x7);
mySerial.print((target >> 7) & 0x7F);
}
// ^^^---------------------//