mBot code in setup() and no code in the loop()


#1

Using the mBlock version 2.1.5.06.16.001, I created a simple mBot visual program starting with the icon mBot, followed by a ‘repeat’ icon with a ‘run forward’ and ‘wait’ icons inside the repeat. It uploads to the arduino successfully but the code is uploads is below. The execution part of the code, i.e. for, motor and delay, should be in the loop function and not the setup.

#include “mBot.h”
#include "MePort.h"
MeBoard myBoard(mBot);
#include “MeDCMotor.h”

double angle_rad = PI/180.0;
double angle_deg = 180.0/PI;
MeDCMotor motor(0);

void setup(){
for(int i=0;i<10;i++)
{
motor.move(1,100);
delay(1000*1);
}

}

void loop(){

}


Arduino forever code generated in setup(), no code in loop()
#2

Can you share a screenshot of your blocks and some of us here can try to recreate it to see if we get the same results?


#3

I think that the only code that goes into the void loop() block is the part of the
code that is inside a “forever” loop in the mblock code. Parts of the code
that only execute a finite amount of times go in the setup. Note that no code can go
after the forever loop…

-Carl