As mentioned in my initial post I am following the structure of the last suggested code in this forum post with suggested changes to library dependencies and port used in software serial:
https://forum.makeblock.com/t/smart-servo-ms-12a-not-working-with-arduino/13438/10
/**
- \par Copyright ©, 2012-2016, MakeBlock
-
@file SmartServoCallback.ino
-
@author MakeBlock
-
@version V1.0.0
-
@date 2017/07/10
-
@brief Description: this file is sample code for Smart servo device.
-
- Function List:
-
- boolean MeSmartServo::assignDevIdRequest(void);
-
- boolean MeSmartServo::moveTo(uint8_t dev_id,long angle_value,float speed,smartServoCb callback);
-
- boolean MeSmartServo::move(uint8_t dev_id,long angle_value,float speed,smartServoCb callback);
-
- \par History:
-
-
- Mark Yan 2017/07/10 1.0.0 build the new
-
*/
#include <SoftwareSerial.h>
#include<MeSmartServo.h>
#include <MeOrion.h>
MeSmartServo mysmartservo(PORT5); //UART2 is on port 5
long loopTime = 0;
void setup()
{
Serial.begin(115200);
mysmartservo.begin(115200);
delay(5);
mysmartservo.assignDevIdRequest();
delay(50);//must delay over 50ms
mysmartservo.setInitAngle(1);
delay(40);
mysmartservo.setZero(1);
delay(40);
loopTime = millis();
}
void loop()
{
mysmartservo.setRGBLed(1, 0, 255, 0);
delay(500);
mysmartservo.move(1, 90, 50); //device ID, angle, speed; absolute angle move;
delay(500);
mysmartservo.setRGBLed(1, 255, 0, 0);
delay(500);
mysmartservo.move(1, 180, 50); //device ID, angle, speed; absolute angle move;
delay(500);
mysmartservo.move(1, 270, 50); //device ID, angle, speed; absolute angle move;
delay(500);
mysmartservo.move(1, 360, 50); //device ID, angle, speed; absolute angle move;
delay(500);
mysmartservo.move(1, -180, 50); //device ID, angle, speed; absolute angle move;
delay(1000);
mysmartservo.move(1, 0, 50); //device ID, angle, speed; absolute angle move;
delay(2000);
}
The RGB LED is not working consistently. It does not change via programming it just remains blue on the motor.
I have tried various power sources: 9V battery and VIN pin on Arduino, 9V battery with positive power line direct to servo and ground to servo and to Arduino, 12V power source. None have made any difference.
I have also tried the example that comes with the latest MakeBlockDrive Arduino library release. No movement.
The wiring is as advised on the Getting Started leaflet for Arduino + Smart Servo. Red Terminal wire that comes with the motor and the 4 wires go Red to Vin, Black to GND, yellow to TX , white to RX
I have tried an UNO board with PORT5 for software serial and a Leonardo. No change
I have two smart servos and neither move.