Question: Note: Our code is for a pololu 3pi robiot. It has 2 LDRs .These LDRs are supposed to find a light and allow the robot

Note: Our code is for a pololu 3pi robiot. It has 2 LDRs .These LDRs are supposed to find a light and allow the robot to steer and follow it. Working code that can be compiled would be much appecitiated :)

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#include #include #include #include #include #include #include #include

Pololu3pi robot; unsigned int sensors[5]; // an array to hold sensor values

void setup() { unsigned int counter; // used as a simple timer

// This must be called at the beginning of 3pi code, to set up the // sensors. We use a value of 2000 for the timeout, which // corresponds to 2000*0.4 us = 0.8 ms on our 20 MHz processor. robot.init(2000);

// Auto-calibration: turn right and left while calibrating the // sensors.0 } void loop() { for (counter=0; counter<80; counter++) { if (counter < 20 || counter >= 60) { OrangutanMotors::setSpeeds(40, -40); } else { OrangutanMotors::setSpeeds(-40, 40); } // This function records a set of sensor readings and keeps // track of the minimum and maximum values encountered. The // IR_EMITTERS_ON argument means that the IR LEDs will be // turned on during the reading, which is usually what you // want. robot.calibrateLineSensors(IR_EMITTERS_ON); // Since our counter runs to 80, the total delay will be // 80*20 = 1600 ms. delay(20); } } OrangutanMotors::setSpeeds(0, 0);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!