trixy_robot_pixy流程图
2016-12-20 19:54:11 0 举报
Arduino pixy robot 程序流程图
作者其他创作
大纲/内容
right();
如果Millis()-encoderTime=5
left();
panServoPos += 10;
objectSize = 20000
开始
speedRight = speedRight-2;
如果blocks==1
如果lastPulseL 0
panServoPos panServoCenter-200
panServoPos = panServoCenter+200
否则
speedLeft = speedLeft-2;
pixy.blocks[0].y 90 && tiltServoPos tiltServoDown
0
如果millis() - pixyTime = 20
}
objectSize = pixy.blocks[0].width * pixy.blocks[0].height;
pixy.blocks[0].y 110 && tiltServoPos tiltServoUp
void Rencoder(){ rpulse=millis()-rtime; // time between last state change and this state change rtime=millis(); // update ltime with time of most recent state change //rcount++;}
encoderTime=millis();lastPulseL = millis() - ltime;lastPulseR = millis() - rtime;
pixy.blocks[0].x 170 && panServoPos panServoLeft
pixy.blocks[0].x 150 && panServoPos panServoRight
tiltServoPos += 10;
如果lastPulseR0
forward();
中断子程序
panServo.writeMicroseconds(panServoPos); tiltServo.writeMicroseconds(tiltServoPos); Serial.print(\"pixy.blocks[0].x = \"); Serial.println(pixy.blocks[0].x); Serial.print(\"pixy.blocks[0].y = \"); Serial.println(pixy.blocks[0].y); Serial.print(\"pixy.blocks[0].width = \"); Serial.println(pixy.blocks[0].width); Serial.print(\"pixy.blocks[0].height = \"); Serial.println(pixy.blocks[0].height); Serial.print(\"objectSize = \"); Serial.println(objectSize);
centerServo(); stop();
设置引脚:H桥:使能:EN1=3; EN2=14\t 方向:directure1=13; directure2=15;中端:lENcoder=10接到0号口; rEncoder=11接 到1号口;舵机:panServo为22; tiltServo为23
objectSize 20000
行走子程序
panServoPos = panServoCenter-200
变量:blocks; objectSize; pixyTime; \t 舵机位置:panServoPos; tiltServoPos; \t encoderTime; ltime; rtime; \t lastPulseL; lastPulseR; 定量:speedLeft=100; speedRight=100;\t motorTime=100;\t lpulse=121; rpulse=121;
void Lencoder(){ lpulse=millis()-ltime; // time between last state change and this state change ltime=millis(); // update ltime with time of most recent state change //lcount++;}
left();
pixyTime = millis();blocks=pixy.getBlocks();
panServoPos -= 10;
tiltServoPos -= 10;
backward();
speedRight = speedRright+2;
如果objectSize 400
speedLeft = speedLeft+2;
收藏
0 条评论
下一页