DFRobot ROB0118 Handbuch - Seite 7

Blättern Sie online oder laden Sie pdf Handbuch für Robotik DFRobot ROB0118 herunter. DFRobot ROB0118 13 Seiten.

2. Download Code
Install the library
firstly. Metro libray
#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();
http://www.dfrobot.com.cn/images/upload/File/20141031110246wu4065.rar
// distance measure command
// Serial initialization
// Sets the baud rate to 9600