I suggest that you make a code like this:
When mbot starts
If ultrasonic sensor range cm < 30 then
Turn right at power 50%
Move forward at power 75%
Your mbot code doesn’t work because mbot cannot multitask.
In the context of computers, multitasking refers to the ability of an operating system or a computer system to execute multiple tasks or processes concurrently. Here are some key points about multitasking in computers:
Multitasking allows a computer to run multiple applications or processes simultaneously, giving the illusion of concurrent execution.
Modern operating systems, such as Windows, macOS, and Linux, have built-in multitasking capabilities.
There are two main types of multitasking: preemptive multitasking and cooperative multitasking.
Preemptive multitasking is the more common approach, where the operating system allocates time slices to each task and switches between them based on priorities or time-sharing algorithms.
Cooperative multitasking relies on the cooperation of individual programs to yield control to other tasks when they are idle. This approach is less common in modern operating systems.
Multitasking enables users to switch between different applications or tasks seamlessly, allowing them to work on multiple things at the same time.
It improves overall system efficiency, as idle time can be utilized by other tasks, maximizing the utilization of system resources.
Multitasking can be seen in action when you have multiple programs running simultaneously, like browsing the internet, listening to music, and working on a document, all happening concurrently.
It’s important to note that the efficiency of multitasking depends on factors such as the system’s resources (CPU, memory), task prioritization, and the capability of the operating system to manage and allocate resources effectively.
Because mbot cannot multitask, it has trouble when it runs the 0.6 second delays and can’t run the other part of the if. If you want me to make you a different code, I will be happy to!