How to play tones (signal) when Mbot is driving backwards


#1

Hello,

I’m new to Mbot/ Mblock.
How can i play tones (warning signal) when Mbot is driving backwards. I can’t find a way to do this. Is it possible to play tones when M1 and M2 (or make for speed a variable) is less then 0?

If it is not possible is it possible to program 2 blocks who run at the same time?
I just can run them one by one.


#2

Hi! The controller can run 2 programs at the same time. Block “mBot Program” can be only 1 copy. So You need to come up with an algorithm that will run in a loop of “forever” and at each change of speed - check whether to play sound.
The easiest option to do is:
изображение


#3

Thank you! I have made this program to continu the sound, and it works :slightly_smiling_face:

Hmmmm :face_with_raised_eyebrow:, by repeating the sound, the motors also keep running (speed -100), and want go to the last speed 0
Do you perhaps have an idea how to solve this?


#4

I think “repeat until” - is needless block. You set speed at 100 and program is cyclic in this block. To keep this block You need change “speed” variable into this block (repeat until), to get out of this block.


#5

As stated, you can only have one mBot Program hat block. Here’s one option to accomplish what you want.

Capture

Please note I have not tested it as I don’t have an mBot with me right now but it gives you the general idea.

Also, if you replace each “mBot Program” hat with a “when space key pressed” hat in the original program, you should get what you were expecting (as Scratch support concurrent execution).

/Aram