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

I am trying to write a program out of pseudocode (I used the LEGO mindstorm NXT

ID: 3678035 • Letter: I

Question

I am trying to write a program out of pseudocode (I used the LEGO mindstorm NXT 2.0). I got the Mario theme song score and implemented it to the LEGO software. I want it to also include that when the touch sensor is pressed (loacted in the back of robot) it moves forward for 1.5 seconds? Don’t know where to add that though, and I don't know if I would just include the Matio Theme Song in like that either…

Until (Mario Theme Song) do

If (unltrasonic sensor is within 25 centemeters of object) then stop

Generate random number between 0 and 100

If (random number < 50) then

Turn 90 degrees right

else

Turn 90 degrees left

end if

else

Move forward

end if

end loop

Explanation / Answer

Try it:

SubProcess Event_loacted_in_the_back_of_robot(coordenate x, coordenate y)
   time=0
   Until (Mario Theme Song) do
       If (unltrasonic sensor is within 25 centemeters of object) then stop
           Generate random number between 0 and 100
           If (random number < 50) then
               Turn 90 degrees right
           else
               Turn 90 degrees left
           end if
       else
           if (time < 90) then // 1,5 minute = 90 seconds
               Move forward
               time = time + 1 // 1 time = 1 seconds
              
           end if
       end if
   end loop
end SubProcess

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