How do you connect and code a servo controller module (8ch) with Arduino Uno?
Hello Everybody! hope everything is well...
I want to start using a new servo controller module (8ch) which i recently bought, i tried to research how to use them but i could not find anything that went into enough depth or explanation of how to use it. What i'm saying is i don't know how to use or even how to connect this ti me arduino Uno. I would appreciate if you could help me with this or if you left a comment with a video/website link where i am able to find info on how to connect, code and use this controller. Appreciate your time! (i have attached a photo of the exact product i bought). Here is the Sample code of the product:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(3, 2);
void setup()
{
mySerial.begin(9600);
delay(100);
}
unsigned int i;
void loop()
{
//cammand : S + PWM + Duty_H + Duty_L + E
for(i=100;i<450;i++)
{
//PWM 1
mySerial.print('S'); //Start
mySerial.print(char(1)); //PWM channel selection
mySerial.print(char(i/0xFF)); //Duty HIGH
mySerial.print(char(i%0xFF)); //Duty LOW
mySerial.print('E'); //End
//PWM 2
mySerial.print('S');
mySerial.print(char(2));
mySerial.print(char(i/0xFF));
mySerial.print(char(i%0xFF));
mySerial.print('E');
delay(5);
}
for(i=450;i>100;i--)
{
mySerial.print('S');
mySerial.print(char(1));
mySerial.print(char(i/0xFF));
mySerial.print(char(i%0xFF));
mySerial.print('E');
mySerial.print('S');
mySerial.print(char(2));
mySerial.print(char(i/0xFF));
mySerial.print(char(i%0xFF));
mySerial.print('E');
delay(5);
}
}
Comments
Best Answer 4 years ago
It obviously uses a dedicated microprocessor, I would start to search for datasheets here.
Usually these noname thingies come from china, so be prepared to use a translotion program or website.
I suspect you need to send specific commands in a specific timeframe to make it work and only the datasheet will help you unless the seller can provide some sample code.
Answer 4 years ago
#include <SoftwareSerial.h>
SoftwareSerial mySerial(3, 2);
void setup()
{
mySerial.begin(9600);
delay(100);
}
unsigned int i;
void loop()
{
//cammand : S + PWM + Duty_H + Duty_L + E
for(i=100;i<450;i++)
{
//PWM 1
mySerial.print('S'); //Start
mySerial.print(char(1)); //PWM channel selection
mySerial.print(char(i/0xFF)); //Duty HIGH
mySerial.print(char(i%0xFF)); //Duty LOW
mySerial.print('E'); //End
//PWM 2
mySerial.print('S');
mySerial.print(char(2));
mySerial.print(char(i/0xFF));
mySerial.print(char(i%0xFF));
mySerial.print('E');
delay(5);
}
for(i=450;i>100;i--)
{
mySerial.print('S');
mySerial.print(char(1));
mySerial.print(char(i/0xFF));
mySerial.print(char(i%0xFF));
mySerial.print('E');
mySerial.print('S');
mySerial.print(char(2));
mySerial.print(char(i/0xFF));
mySerial.print(char(i%0xFF));
mySerial.print('E');
delay(5);
}
}
Answer 4 years ago
So i found the code, i have never worked with PWM, would you be able to simply explain some of this for me?
Answer 4 years ago
Right! appreciate it, i will try and see what i can find.
4 years ago
So... Googling the title of this topic (question) didn't help?
Answer 4 years ago
not for me sadly, specially with restricted internet services.