Onboard Button Press


Hey i did this program, but it did not work

I wanna,
when i press onboard button one few this robot turn left,
when i press two few this robot turn right,
when i press three this robot back

Can i do this? Can use onboard button like that?



I’d suggest that you add a short wait (.25 ms or less) at the bottom of the forever loop to account for “debouncing” the button, but I’ve done something similar in my eBook (link) on using mBlock with the mBot. :slight_smile:


Hi aalimkeskinn,
You may try below program

Press one, turn left;
press two, turn right;
press three, back;
press four, stop;
press five, turn left;


Thanks, for help. i did this code blocks


i do this program for my mbot on image but i am getting this error?

Why i am getting this error? How can i solution this problem?


You have nested forever loops. The error message is pointing out that this is the case. You can only have one forever loop per program because it corresponds to the loop() method in the Arduino sketch. :slight_smile: