I need help coverting this Arduino code into C/C++ langauge. void follow_block(i
ID: 3834718 • Letter: I
Question
I need help coverting this Arduino code into C/C++ langauge.
void follow_block(int tracked_block)
{
long block_size = pixy.blocks[tracked_block].height * pixy.blocks[tracked_block].width;
if(block_size < MAX){
Serial.print("Signature: ");
Serial.println(pixy.blocks[tracked_block].signature);
Serial.println(block_size);
motors.setRightSpeed(400);
motors.setLeftSpeed(400);
}
else{
fd_block = 1;
}
}
int mov = 0;
void find_block()
{
if(mov == 0){
motors.setRightSpeed(-200);
motors.setLeftSpeed(200);
}
else if(mov == 1){
motors.setRightSpeed(200);
motors.setLeftSpeed(-200);
}
else if(mov == 2){
motors.setRightSpeed(400);
motors.setLeftSpeed(400);
}
else{
motors.setRightSpeed(-400);
motors.setLeftSpeed(-400);
}
mov = random(0,3);
delay(500);
}
Explanation / Answer
void follow_block(int tracked_block)
{
long block_size = pixy.blocks[tracked_block].height * pixy.blocks[tracked_block].width;
if(block_size < MAX){
Serial.print("Signature: ");
Serial.println(pixy.blocks[tracked_block].signature);
Serial.println(block_size);
motors.setRightSpeed(400);
motors.setLeftSpeed(400);
}
else{
fd_block = 1;
}
}
int mov = 0;
void find_block()
{
if(mov == 0){
motors.setRightSpeed(-200);
motors.setLeftSpeed(200);
}
else if(mov == 1){
motors.setRightSpeed(200);
motors.setLeftSpeed(-200);
}
else if(mov == 2){
motors.setRightSpeed(400);
motors.setLeftSpeed(400);
}
else{
motors.setRightSpeed(-400);
motors.setLeftSpeed(-400);
}
mov = random(0,3);
delay(500);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.