Where is the "play tone on note"


#1

Hello

I want to let my mBot play tone just like racing signal in 3 sec and the same time check whether “button pressed”.

if button is pressed in 3 sec then mBot run ahead.if not, mBot run back.


I want to do this with “play tone on note xx” and “repeat 10” and “if”.

The flow is

  1. " play tone on note C3 " then check 10 times “button pressed” in 1sec.

  2. " play tone on note C3" and check 10 times “button pressed” in 1sec again.

  3. " play tone on note C4" and check 10 times “button pressed” in 1sec again.

  4. if “button pressed” in last 3 step, mBot run ahead. if “button not pressed” in last 3 step, mBot run back.

But I can not find “play tone on note xx” in mblock 3.2.2 now.

There is only “play tone on note xx beat xx”.

If I use this,i can not check whether “button pressed” at the same time.

Can anyone help me. Thank you.


#2

The new version of play tone on note is play tone on note xx beat xx. The beat just determines the length of the note. A whole note should play for one second, half note for half a second, etc.

I’m not quite clear on your logic. Is it something like below?

While timer < 1 second
Play tone C3 for beat Whole
If button pressed
Run forward
While timer < 1 second
Play tone C3 for beat Whole
If button pressed
Run forward
While timer < 1 second
Play tone C4 for beat Whole
If button pressed
Run forward
Else
Run backward
Stop tone

If not, could you clarify in the format above? From your description it is difficult to tell whether the button press in the first two seconds needs to trigger a Run Forward event or not


#3

Hello, chuckmcknight

Almost like what you describe


While timer < 1 second
{
__ Play tone C3 for beat Whole
__ If button pressed
__ {
__ Run forward 3 sec
__ End or Stop program
__ }
}
While timer < 1 second
{
__ Play tone C3 for beat Whole
__ If button pressed
__ {
__ Run forward 3 sec
__ End or Stop program
__ }
}
While timer < 1 second
{
__ Play tone C4 for beat Whole
__ If button pressed
__ {
__ Run forward 3 sec
__ End or Stop program
__ }
}
Run back 3 sec
End or Stop program


#4

Based on your posting (and I hope this isn’t a school homework assignment), you’d do something like this:


#5