uKit Explore
  • About uKit Explore
  • Quick Start
    • How to Install uKit Explore Arduino Library
    • uKit Explore v2 Pinout
    • Introduction to Grayscale Sensor and Frequently Asked Questions
    • Grayscale Sensor Calibration Guidelines
    • Grayscale Sensor Firmware Update
  • uKit Explore Function
    • Introduction to uKit Explore Library
    • Sensor
      • uKit eye lamp
        • setEyelightAllPetals(id,red,green,blue)
        • setEyelightPetals(id,petalsnum,petals)
        • setEyelightLook(id,face,times,red,green,blue)
        • setEyelightLookUntil(id,face,times,red,green,blue)
        • setEyelightScene(id,scene,times);
        • setEyelightSceneUntil(id,scene,times)
        • setEyelightOff(id)
      • uKit Ultrasonic Sensor
        • setUltrasonicRgbled(id,red,green,blue)
        • setUltrasonicRgbledOff(id)
        • readUltrasonicDistance(id)
      • uKit Infrared Sensor
        • readInfraredDistance(id)
      • uKit Touch Sensor
        • readButtonValue(id)
      • uKit Light Sensor
        • readLightValue(id)
      • uKit Sound Sensor
        • readSoundValue(id)
      • uKit Temperature and Humidity Sensor
        • readHumitureValue(id,choice)
      • uKit Color Sensor
        • readColorRgb(id)
        • readColor(id,color)
    • uKit Servo Motor
      • setServoTurn(id,dir, speed)
      • setServoAngle(id,angle,times)
      • readServoAngleNPD(id)
      • readServoAnglePD(id)
    • uKit DC Motor
      • setMotorTurnAdj(id, speed,time)
      • setMotorTurn(id,pwmDuty)
      • setMotorStop(id)
      • readMotorSpeed(id)
    • uKit Explore Onboard Hardware
      • Onboard button
        • button1.Update();
        • button1.clicks()
      • Onboard Buzzer
        • noTone(pin)
        • tone(frequency, duration)
      • Onboard RGB LED
        • setRgbledColor(red,green,blue)
      • onboard Battery Voltage Level
        • readBatteryVoltage()
      • onboard Gyroscope
        • IMU::init()
        • IMU::read()
        • IMU::getRawAccelX()
        • IMU::getRawAccelY()
        • IMU::getRawAccelZ()
        • IMU::getRawGyroX()
        • IMU::getRawGyroY()
        • IMU::getRawGyroZ()
        • IMU::getRoll()
        • IMU::getPitch()
  • Arduino Function
Powered by GitBook
On this page
  • Parameter
  • Example

Was this helpful?

  1. uKit Explore Function
  2. uKit DC Motor

setMotorTurnAdj(id, speed,time)

Set the motor to rotate at constant speed (non-blocking)

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: r/ min, range: -140 ~ 140

time

int

Set the rotation time: unit: 1ms, when the motor rotates for the specified time, the motor automatically stops rotating, 0xFFFF means that it will always rotate

About the difference between speed and PWM mode: speed mode is a closed-loop control that allows the motor to maintain a certain speed. The disadvantage: forward and backward switching requires 100ms waiting. The PWM mode is simply to control the rotation speed with voltage, and the forward and backward rotation can be switched without waiting. Disadvantages: The speed will be changed by the weight of the car.

Example

Use uKit Explore v2 board to control the DC Motor ID-1 to rotate counterclockwise all the time at the speed of 80.

#include "uKitExplore2.h"
void setup() {    
    Initialization();    
    setMotorTurnAdj(1,-80,0xffff);
     
}

void loop() {   
 }

Use the uKit Explore v2 board to control the DC Motor ID-1 to rotate counterclockwise all the time with the speed 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;
    }    
    setMotorTurnAdj(1,-(speed),0xffff);
}
PreviousuKit DC MotorNextsetMotorTurn(id,pwmDuty)

Last updated 5 years ago

Was this helpful?