Microsoft MakeCode

Infrared remote for multi-tasking

Hi, i’m trying to use an infrared remote to control my robot for doing different kind of tasks.

Just like by using button A/B for interrupt a loop. However, it doesn’t work. The coding only allow button A to interrupt the loop but not infrared button NUM1. Here’s my simple coding.

Anyone can help to solve it? Many thanks!

Put a “set a to true” in “on start” and test it.
I think otherwise the variable is block-scoped which means in reality you have three different Variables named a and not one which is changed.

Hi MK,

Thanks for your suggestion. However, it doesn’t work. In this simple coding example, the purpose is to show “small heart” when infrared remote control button “NUM1” is pressed, so as to testify the while loop has been interrupted by infrared remote control.

However, as said, it seems only button “A” in microbit can interrupt the while loop not the infrared remote control.

Is there any solution for that?

Many thanks!