Question: Please see the Arduino code below as the basis for bot movement: / / code starts here const int AIN 1 = 1 1 ;

Please see the Arduino code below as the basis for bot movement:
//code starts here
const int AIN1=11;
const int AIN2=12;
const int PWMA =10;
const int BIN1=8;
const int BIN2=7;
const int PWMB =9;
void setup()
{
pinMode(AIN1, OUTPUT);
pinMode(AIN2, OUTPUT);
pinMode(PWMA, OUTPUT);
pinMode(BIN1, OUTPUT);
pinMode(BIN2, OUTPUT);
pinMode(PWMB, OUTPUT);
}
void loop()
{
// pause for 1/2 second--get ready!
delay(500);
//"Forward"
digitalWrite(AIN2, LOW);
digitalWrite(AIN1, HIGH);
digitalWrite(BIN2, LOW);
digitalWrite(BIN1, HIGH);
analogWrite(PWMA,150);
analogWrite(PWMB,150);
delay(500);
analogWrite(PWMA,0);
analogWrite(PWMB,0);
delay(250);
//Turn one way or the other
digitalWrite(AIN2, LOW);
digitalWrite(AIN1, HIGH);
digitalWrite(BIN1, LOW);
digitalWrite(BIN2, HIGH);
analogWrite(PWMA,256/2);
analogWrite(PWMB,256/2);
delay(250);
analogWrite(PWMA,0);
analogWrite(PWMB,0);
delay(250);
//"Reverse"
digitalWrite(AIN1, LOW);
digitalWrite(AIN2, HIGH);
digitalWrite(BIN1, LOW);
digitalWrite(BIN2, HIGH);
analogWrite(PWMA,256/2);
analogWrite(PWMB,256/2);
delay(250);
analogWrite(PWMA,0);
analogWrite(PWMB,0);
//infinite while loop to stop the program
while (true)
{
delay(10);
}
}
Can the coding above for bot movement be utilized in conjunction with the problem below:
Objectives Follow arbitrary lines of various colors.
Introduction You will need an Arduino robot which is able to
Drive around on the table by itself.
Respond to light from the photoresistor
Display useful information on the LCD
Respond to a button
The photoresistor needs to be within about (one finger width) off the table facing down, there are various ways to do this, but you almost for sure need to extend the wire lead length. To increase sensitivity of the photoresistor, it also helps to reduce stray light, this can be done with a black paper tube, I have paper and tape available for this during class. Construction of the Color sensor is shown below: Spliced and soldered wires to extend the light sensor could look like this: Insulate one or both legs Wrap a tight black paper tube to (1)/(2) from the end If you have not installed the battery pack between the wheels to improve traction, this would be a good time to move it forward. If the wheels slip during turns, accurate line tracking will be more difficult. The color duct tape your bot will follow is higher friction than the table surface and tends to catch the paper-clip tail drag; making repeatability problematic.
Requirements
1) The first problem is to find suitable light values for white tape, red tape, yellow tape, green tape, and black table-top surface i.e. you are calibrating the Light sensor to act as a Color sensor. Once you know these values, you will be able to program your bot to recognize these colors and make specific actions based on that information. Read and remember this: sensing color is not easy, you need to control things such as the distance your sensor is from the table, angle your sensor has to the table, ambient light, shadows from you or other students hovering over your bot, and various other factors.
Consistency of your robot depends on you making measurements which are consistent with what the robot will see. When your bot seems to no longer sense colors correctly you may need to re-calibrate. Build your bot capable of movement, but in this first task, just place your bot manually. Your bot should display the analog output (01023) of the Light/Color sensor to the LCD. Record values from various places on the table-top (black) and colored tapes.
Adjust your light sensor to try and achieve the largest difference/separation between the colors. Find the minimum and maximum values for all the different colors. Then graph them on a number-line (01023) below. If light values overlap for different colors, try to adjust your sensor and/or re-read the previous paragraph. Find maximum and minimum values which are unique for each color. Dont be approximate, dont hurry, take lots of data. __________________________________________________________________________________01023
2) Place the Bot at one corner on the outer-edge of the white tape. The bot should wait until you start it with a button push. The Bot must follow the outer-edge of the white tape. It must follow around corners, although it can swing out, it must not reverse direction or hit a wall. For sign-off, you must complete at least one lap without crossing over the tape (outer edge to inner edge) or hitting a wall.

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 Programming Questions!