Homeworkassignment 2
Homeworkassignment 2
2 Questions
1) Can you explain its motion based upon the program?
OnFwd(LEFTRIGHT, 75);Bot moves forward at 75% power because both
A and C outputs are turned on in Fwd direction
while(true)
{
until(SENSOR_1==1);Bot continues its movement until the sensor
is pressed when the bot hits an obstacle
OnRev(LEFTRIGHT, 75);Bot then reverses direction at 75% power
Wait(REV_TIME);Bot reverses for 500ms
OnFwd(LEFT, 75);Output A is activated in the forward direction
causing the bot to spin
Wait(SPIN_TIME);Bot spins for 700ms
OnFwd(RIGHT, 75);Output C is activated in the forward direction
which causes the bot to travel straight forward again.
}
2) What is the effect of changing the values of REV_TIME and SPIN_TIME?
Increasing REV_TIME will cause the bot to back up further after
it contacts an obstacle
Decreasing REV_TIME will cause the bot to back up a shorter
distance
Increasing SPIN_TIME will cause the bot to spin for a longer
time
Decreasing SPIN_TIME will cause the bot to spin for a shorter
time
3) Why is it advantageous to use #define to declare these constants?
When these values are used in multiple places in the program
the value can be edited by changing only one line of code. You
can also give the constants a name that makes your program
easier to understand.