Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Start Stop Turn the car on and let it move (Note: After this command, the car wi

ID: 2293859 • Letter: S

Question

Start

Stop

Turn the car on and let it move
(Note: After this command, the car will keep moving forever, unless you say 'turn off the car' )

Turn off the car

Turn the steering wheel right    
(Note: After this command, the car will keep steering right, unless you give another steering command.)

Turn the steering wheel left
(Note: After this command, the car will keep steering left, unless you give another steering command.)

Keep the steering wheel neutral
(Note: After this command, the car will keep moving straight, unless you give another steering command.)

Are both sensors seeing white?

Are both sensors seeing black?

Is the left sensor seeing white, and the right sensor seeing black?

Is the right sensor seeing white, and the left sensor seeing black?

For simplicity you can assume that you can execute the steering commands infinitely fast, and also that the color sensors and the whole code runs infinitely fast!

Explanation / Answer

Possible to have 2 sensors near the line, with the third placed linearly a bit to one side. The third changes the "polarity of the detection scheme. The program would have the 2 close line sensors following their respective colors, and generate slowing commands for each wheel to turn the robot to where the line is estimated to be. Could be :

if right = white and left = black then forward ' black line on white back inside follower
if right = black and left = white then right ' sharp turn
if right = black and left = black then slow_right ' easy turn
if right = white and left = white then left ' sharp turn
then have before this group a line that tests the far sensor for white or black, that inverts the above tests. might place this sensor on the far outside to prevent false early triggering.

//this will work for both contrasts...

if(left_sensor=right_sensor)

move forward

//while on white line

if(middle_sensor=white&(left_sensor is more white than right_sensor))

turn left

if(middle_sensor=white&(right_sensor is more white than left_sensor))

turn right

//while on black line

if(middle_sensor=black&(left_sensor is more white than right_sensor))

turn right

if(middle_sensor=black&(right_sensor is more white than left_sensor))

turn left

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote