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


#1

Hi,

I’m trying out mBlock for the first time. I added a forever loop with a single dummy statement (set pin 9 high), connected to “when Arduino starts up”. I was surprised to see that all the code was generated in setup():

void setup() {
  pinMode(9,OUTPUT);
  while(1) {
      digitalWrite(9,1);
      _loop();
  }
}

void _loop() {
}

void loop() {
  _loop();
}

I would have expected something more like:

void setup() {
  pinMode(9, OUTPUT);
}

void loop() {
  digitalWrite(9, 1);
}

Is there something that I’m missing in order to get code to be added to loop()? I did find another thread here where someone was seeing no code in loop() (mBot code in setup() and no code in the loop()), but in that case it was because they were using a finite “repeat” block rather than “forever”, which makes sense.

I’m using mBlock 5.1.0 on Mac OS X 10.14.6 with an Arduino Mega2560.

Thanks!


#2

Hello, can you send us your code? So that I can confirm with our R&D colleagues.


#3

Hi,

Sure thing. Here is a screenshot of the program:


#4

Hi, I have confirmed with our R&D, we did have some special processing with Arduino compile, so it has a little difference with normal Arduino code.