...
The Lynxmotion Smart Servos (LSS) are compact, modular and configurable actuators that provide greater control than standard PWM servos. The servo lineup currently includes three “smart servos” which appear physically the same, sharing the same dimensions and mounting points but differing in maximum torque and speed.
...
The lynx motion has a simple serial protocol for controlling the motor, that is human-readable:
Number sign #
Servo ID number as an integer
Action command (two to three letters, no spaces, capital or lower case)
Configuration value in the correct units with no decimal
End with a control / carriage return '<cr>'
Ex: #5PD1443<cr>
Additional Parts:
...
Possible Solution: This is one solution but it could use some improvement: It needs a denounce and a pause without delay function to avoid blocking your code. This solution uses an older arduino library that might need to be updated.
Code Block | ||
---|---|---|
| ||
#include <LSS.h> #include <SoftwareSerial.h> SoftwareSerial servoSerial(8, 9); // ID set to default LSS ID = 0 #define LSS_ID (0) #define LSS_BAUD (LSS_DefaultBaud) // Create one LSS object LSS myLSS = LSS(LSS_ID); int ServoPosition = 0; bool counting = true; int resetTime = 0; int lastMovement; void setup() { servoSerial.begin(LSS_BAUD); // Initialize the LSS bus LSS::initBus(servoSerial, LSS_BAUD); Serial.begin(LSS_BAUD); myLSS.move(0); // allow time to move to 0 position delay(3000); myLSS.setMaxSpeed(600, LSS_SetConfig); //buttons pinMode(11, INPUT); pinMode(10, INPUT); } void loop() { delay(1000); if (counting) { int seconds = (millis() - resetTime)/1000; // see below for an explanation of resetTime ServoPosition = seconds * 60; // if we divide 360 by 60 we get 6.0 degrees myLSS.move(ServoPosition); // move servo to position Serial.println(seconds); lastMovement = millis(); } else { resetTime = millis() - lastMovement; // this helps us return to the last position of the clock movement } // buttons if (digitalRead(10) == HIGH) { // stop or start counting = !counting; Serial.println("Start/Stop"); // this could be improved on with a debounce! } if (digitalRead(11) == HIGH) { // reset Serial.println("reset"); myLSS.move(0); delay(2000); resetTime = millis(); // we use this to restart our counter from 0 } } |
...