#include "pbot.h" pbot PBOT; void setup() { // put your setup code here, to run once: PBOT.BEGIN(); } void loop() { // put your main code here, to run repeatedly: if( PBOT.COL1_RIGHT() == HIGH && PBOT.COL2_CENTER() == LOW && PBOT.COL3_LEFT() == HIGH) { fwd(); delay (2000); right_full(); delay (3000); } } void fwd(){ PBOT.DIRECTION(MOTOR_A,MOTOR_FWD); PBOT.DIRECTION(MOTOR_B,MOTOR_FWD); PBOT.SPEED(MOTOR_A, 80); PBOT.SPEED(MOTOR_B, 80); } void back(){ PBOT.DIRECTION(MOTOR_A,MOTOR_REV); PBOT.DIRECTION(MOTOR_B,MOTOR_REV); PBOT.SPEED(MOTOR_A, 80); PBOT.SPEED(MOTOR_B, 80); } void left(){ PBOT.DIRECTION(MOTOR_A,MOTOR_FWD); PBOT.DIRECTION(MOTOR_B,MOTOR_FWD); PBOT.SPEED(MOTOR_A, 0); PBOT.SPEED(MOTOR_B, 80); } void left_full(){ PBOT.DIRECTION(MOTOR_A,MOTOR_REV); PBOT.DIRECTION(MOTOR_B,MOTOR_FWD); PBOT.SPEED(MOTOR_A, 80); PBOT.SPEED(MOTOR_B, 80); } void right(){ PBOT.DIRECTION(MOTOR_A,MOTOR_FWD); PBOT.DIRECTION(MOTOR_B,MOTOR_FWD); PBOT.SPEED(MOTOR_A, 80); PBOT.SPEED(MOTOR_B, 0); } void right_full(){ PBOT.DIRECTION(MOTOR_A,MOTOR_FWD); PBOT.DIRECTION(MOTOR_B,MOTOR_REV); PBOT.SPEED(MOTOR_A, 80); PBOT.SPEED(MOTOR_B, 80); } void stop(){ PBOT.SPEED(MOTOR_A, 0); PBOT.SPEED(MOTOR_B, 0); } Please correct the code above. instruction: if the robot detects a wall in its right and left sensor, move forward for 2 seconds then rotate clockwise for 3 seconds.
#include "pbot.h"
pbot PBOT;
void setup() {
// put your setup code here, to run once:
PBOT.BEGIN();
}
void loop() {
// put your main code here, to run repeatedly:
if( PBOT.COL1_RIGHT() == HIGH && PBOT.COL2_CENTER() == LOW && PBOT.COL3_LEFT() == HIGH) {
fwd();
delay (2000);
right_full();
delay (3000);
}
}
void fwd(){
PBOT.DIRECTION(MOTOR_A,MOTOR_FWD);
PBOT.DIRECTION(MOTOR_B,MOTOR_FWD);
PBOT.SPEED(MOTOR_A, 80);
PBOT.SPEED(MOTOR_B, 80);
}
void back(){
PBOT.DIRECTION(MOTOR_A,MOTOR_REV);
PBOT.DIRECTION(MOTOR_B,MOTOR_REV);
PBOT.SPEED(MOTOR_A, 80);
PBOT.SPEED(MOTOR_B, 80);
}
void left(){
PBOT.DIRECTION(MOTOR_A,MOTOR_FWD);
PBOT.DIRECTION(MOTOR_B,MOTOR_FWD);
PBOT.SPEED(MOTOR_A, 0);
PBOT.SPEED(MOTOR_B, 80);
}
void left_full(){
PBOT.DIRECTION(MOTOR_A,MOTOR_REV);
PBOT.DIRECTION(MOTOR_B,MOTOR_FWD);
PBOT.SPEED(MOTOR_A, 80);
PBOT.SPEED(MOTOR_B, 80);
}
void right(){
PBOT.DIRECTION(MOTOR_A,MOTOR_FWD);
PBOT.DIRECTION(MOTOR_B,MOTOR_FWD);
PBOT.SPEED(MOTOR_A, 80);
PBOT.SPEED(MOTOR_B, 0);
}
void right_full(){
PBOT.DIRECTION(MOTOR_A,MOTOR_FWD);
PBOT.DIRECTION(MOTOR_B,MOTOR_REV);
PBOT.SPEED(MOTOR_A, 80);
PBOT.SPEED(MOTOR_B, 80);
}
void stop(){
PBOT.SPEED(MOTOR_A, 0);
PBOT.SPEED(MOTOR_B, 0);
}
Please correct the code above.
instruction: if the robot detects a wall in its right and left sensor, move forward for 2 seconds then rotate clockwise for 3 seconds.
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)