Go Down

Topic: Worst Combo, Newb and LewanSoul Serial Servos! (Read 669 times) previous topic - next topic

slugbut

Hi,

I'm using some LX-15D Lewansoul serial servos and being a newb I'm struggling.

I'm at the stage where I now have the servo connected to a nano and its doing a simple sweep.
The servo is connected to their debug board on the RX and TX of the nano and a GND

Using a standard servo the rotary pot would be connected to 0 and the servo on 9 and all is well but how do I change the code so that the command is sent through the RX and TX to the serial servo?


thanks, I've attached the code due to exceeding the 9000 characters.

Jon

vinceherman

#1
Apr 19, 2019, 02:35 pm Last Edit: Apr 19, 2019, 08:41 pm by vinceherman
Using a standard servo the rotary pot would be connected to 0 and the servo on 9 and all is well but how do I change the code so that the command is sent through the RX and TX to the serial servo?
Jon
What rotary pot?  What are you trying to do?  Something like the servo knob tutorial, where a pot is used as input and the servo position is set from the pot reading?

What are you doing in your loop?

Code: [Select]
void loop() {
  // put your main code here, to run repeatedly:
  LobotSerialServoMove(Serial, ID1, 100, 500);
  LobotSerialServoMove(Serial, ID2, 500, 500);
  delay(5000);
  LobotSerialServoMove(Serial, ID1, 500, 500);
  LobotSerialServoMove(Serial, ID2, 600, 500);
  delay(500);
  LobotSerialServoMove(Serial, ID1, 900, 500);
  LobotSerialServoMove(Serial, ID2, 700, 500);
  delay(1000);
  LobotSerialServoMove(Serial, ID1, 500, 500);
  LobotSerialServoMove(Serial, ID2, 600, 500);
  delay(10000);
}


It looks to me like you have 2 servos moving. 
The first servo goes to position 500 and the second servo goes to position 600.
Then you wait 5 seconds.
Then you repeat this several times with different servo positions.

What do you see in the servo knob tutorial?

Code: [Select]
void loop() {
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there
}


Read a pot value.
Map that pot reading value into a servo position value.
Tell your servo to move to that servo position.

Have you tried adding an analog read to get the value of the pot?
Then you can map it to a servo position.
Then you can tell your servo to move to that position.

Go Up