setMotorTurn(id,pwmDuty)
Set the rotation speed of the DC motor using PWM.
Parameter
Parameters
Type
Description
id
unsigned char
ID number to be controlled, range 0 ~ 18
speed
int
Set motor rotation speed. Positive numbers indicate clockwise rotation, negative numbers indicate counterclockwise rotation, unit: pwm, range: -140 ~ 140
Example
Use uKit Explore v2 board to control the DC Motor ID-1 to rotate counterclockwise all the time with the PWM is 80
#include "uKitExplore2.h"
void setup() {
Initialization();
setMotorTurn(1,-80);
}
void loop() {
}
Use the uKit Explore v2 board to control the DC Motor ID-1 to rotate counterclockwise all the time with the PWM slowly increases from 0 to the maximum speed.
#include "uKitExplore2.h"
int speed=0;
void setup() {
Initialization();
}
void loop() {
speed++;
if(speed>=255){
seed=255;
}
setMotorTurn(1,-(speed));
}
Last updated
Was this helpful?