DFRobot ROB0118 Manual - Page 9

Browse online or download pdf Manual for Robotics DFRobot ROB0118. DFRobot ROB0118 13 pages.

if(pos>119)
iable again
}else {
if(pos>=60 && pos<=120){
pos=pos-1;
myservo.write(pos);
}
if(pos<61)
}
}
STEP 5: Debugging Robot
#include <Servo.h>
#include <Metro.h>
Metro measureDistance = Metro(50);
Metro sweepServo = Metro(20);
int speedPin_M1 = 5;
int speedPin_M2 = 6;
int directionPin_M1 = 4;
int directionPin_M2 = 7;
unsigned long actualDistance = 0;
Servo myservo;
// create servo object to control a servo
int pos = 60;
int sweepFlag = 1;
int URPWM = 3; // PWM Output 0-25000US,Every 50US represent 1cm
int URTRIG= 10; // PWM trigger pin
uint8_t EnPwmCmd[4]={0x44,0x02,0xbb,0x01};
void setup(){
myservo.attach(9);
sweepFlag = false;
sweepFlag = true;
//M1 Speed Control
//M2 Speed Control
//M1 Direction Control
//M1 Direction Control
// assign the var
// distance measure command
// Serial initialization