Question: Im struggling to make a function that will cause the simulated robot to drive forwards over the background until one of the light sensors detects

Im struggling to make a function that will cause the simulated robot to drive forwards over the background until one of the light sensors detects a change in the colour of the background and also provide a simple test program that demonstrates your function behaves as expected and make a second function that will accept two parameters and will cause the simulated robot to turn by a specified amount in a specified direction. Using two functions, or otherwise, im struggling to make a program that will cause the simulated robot to drive over the Grey_bands background and demonstrate a change in direction each time a change is detected in the colour of the background. When the robot detects the black line, it should draw a circle and the program should end. Use the following block magic when running your program. %%sim_magic_preloaded -Cp -b Grey_bands -x 100 -y 350 -a 0 the code ( %%sim_magic_preloaded -Cp -b Grey_bands -x 100 -y 350 -a 0) is automaticly uploaded to the vce enviroment whcich is comprised with all the codes needed to help make the tank move, dont call it robot in your code as it wont move, motor import MoveTank, MoveSteering, SpeedPercent, OUTPUT_B, OUTPUT_C from ev3dev2.sensor import INPUT_1, INPUT_2, INPUT_3, INPUT_4 from ev3dev2.sensor.lego import ColorSensor, GyroSensor, UltrasonicSensor from ev3dev2.sound import Sound from ev3dev2_glue import get_clock speaker = Sound() def say(txt, wait=False, show=True): """Say and optionally show a phrase.""" if show: print(txt) # `wait` controls blocking behaviour speaker.speak(txt, play_type=int(not wait)) tank_turn = MoveSteering(OUTPUT_B, OUTPUT_C) tank_drive = MoveTank(OUTPUT_B, OUTPUT_C) ultrasonic = UltrasonicSensor(INPUT_1) colorLeft = ColorSensor(INPUT_2) colorRight = ColorSensor(INPUT_3) gyro = GyroSensor(INPUT_4) -----your code below-----

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!