DFRobot ROB0117 Manual de inicio rápido - Página 9
Navegue en línea o descargue pdf Manual de inicio rápido para Microcontroladores DFRobot ROB0117. DFRobot ROB0117 13 páginas. Basic kit for cherokey 4wd
2015/11/4
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;
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);
Serial.begin(9600);
SensorSetup();
}
void loop(){
if(measureDistance.check() == 1){
actualDistance = MeasureDistance();
//
Serial.println(actualDistance);
//
delay(100);
}
if(sweepServo.check() == 1){
servoSweep();
}
https://www.dfrobot.com/wiki/index.php?title=Basic_Kit_for_Cherokey_4WD_SKU:ROB0117
Basic Kit for Cherokey 4WD SKU:ROB0117 - Robot Wiki
// distance measure command
// Serial initialization
// Sets the baud rate to 9600
9/13