Page 1
Basic Kit for Turtle 2WD SKU:ROB0118 Function Introduction This Kit will teach you how to build a automatic obstacle - avoidance robot which is achieved on the platform of the Turtle Robot,based on ultrasonic sensor as distance measuring device,and combined with servo. STEP 1: Assemble Robot Refer to Instruction Manual http://www.dfrobot.com.cn/image/data/ROB0005/CN/ROB0005%20InstructionManual%20V1.1.pdf...
Page 2
2. Finished the robot chassis.Then following the connection diagram to wire the hardware. Motor Connection Physical map...
Page 3
STEP 2: Debug Motor Download the Code int speedPin_M1 = 5; //M1 Speed Control int speedPin_M2 = 6; //M2 Speed Control int directionPin_M1 = 4; //M1 Direction Control int directionPin_M2 = 7; //M1 Direction Control void setup(){ void loop(){ carAdvance(100,100); delay(1000); carBack(100,100); delay(1000); carTurnLeft(250,250);...
Page 7
2. Download Code Install the library firstly. Metro libray http://www.dfrobot.com.cn/images/upload/File/20141031110246wu4065.rar #include <Servo.h> #include <Metro.h> Metro measureDistance = Metro(50); Metro sweepServo = Metro(20); unsigned long actualDistance = 0; Servo myservo; // create servo object to control a servo int pos = 60;...
Page 8
void SensorSetup(){ pinMode(URTRIG,OUTPUT); // A low pull on pin COMP/TRIG digitalWrite(URTRIG,HIGH); // Set to HIGH pinMode(URPWM, INPUT); // Sending Enable PWM mode comm for(int i=0;i<4;i++){ Serial.write(EnPwmCmd[i]); int MeasureDistance(){ // a low pull on pin COMP/TRIG triggering a se nsor reading digitalWrite(URTRIG, LOW);...
Page 9
if(pos>119) sweepFlag = false; // assign the var iable again }else { if(pos>=60 && pos<=120){ pos=pos-1; myservo.write(pos); if(pos<61) sweepFlag = true; STEP 5: Debugging Robot #include <Servo.h> #include <Metro.h> Metro measureDistance = Metro(50); Metro sweepServo = Metro(20); int speedPin_M1 = 5; //M1 Speed Control int speedPin_M2 = 6;...
Page 11
carAdvance(70,70); Serial.println("carAdvance"); delay(100); carBack(150,150); void SensorSetup(){ pinMode(URTRIG,OUTPUT); // A low pull on pin COMP/TRIG digitalWrite(URTRIG,HIGH); // Set to HIGH pinMode(URPWM, INPUT); // Sending Enable PWM mode comm for(int i=0;i<4;i++){ Serial.write(EnPwmCmd[i]); int MeasureDistance(){ // a low pull on pin COMP/TRIG triggering a sensor r eading digitalWrite(URTRIG, LOW);...
Page 13
// tell servo to go to po sition in variable 'pos' if(pos>119) sweepFlag = false; // assign the var iable again else { if(pos>=60 && pos<=120){ pos=pos-1; myservo.write(pos); if(pos<61) sweepFlag = true; Your own car was born! https://www.dfrobot.com/wiki/index.php/Basic_Kit_for_Turtle_2WD_SKU:ROB0118 6-1-17...
Need help?
Do you have a question about the ROB0118 and is the answer not in the manual?
Questions and answers