A-Star 32u4 Mini does not auto-reset on connect

Hi there,

I have a A-Star 32U4 mini board and the setup function is never called.
The board is directly connected to PC via a USB cable.
The code is below.
Serial monitor from Arduino software only shows looplooploop…
It never show “setup”.

Why?
and how can I make it to auto-reset?

thanks,
mihai

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600); 

  Serial.write("setup");
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.write("loop");
  delay(3000);
}

Hello.

Most likely the code runs before the Serial Monitor. You can add while (!Serial) before Serial.write("setup"); to wait for the Serial Monitor to connect to your A-Star. You might find it helpful to look at the if(Serial) page on the Arduino website.

- Amanda

Hi,

I added that, but it only prints “setup” once at the first connect (after uploading the sketch).
If I close the Serial Monitor, and then start it again, the “setup” string is not printed anymore.

I suspect that the board does not auto-reset on connect.

The normal behaviour of all Arduino boards that I have is to auto-reset on connect from Serial port. This is a very useful feature as it clears the allocated memory in the previous run.

Please explain how to make it to auto-reset on connect.

thanks,
mihai

Not all Arduino official boards have the auto-reset (on serial connection) feature you are referring to. For example, the Arduino Leonardo does not reset when a serial connection is established, since it uses a different solution for USB and serial. You can find those details on the Getting Started with the Arduino Leonardo, Leonardo ETH and Micro page on the Arduino website. That also applies to the A-Star 32U4, which uses the same AVR chip (ATmega32U4). You might try opening the A-Star’s serial port with 1200 baud and then close it as described on the DisablingAutoResetOnSerialConnection page on the Arduino website. This will cause the board to go into bootloader mode for about 8 seconds and then restart the sketch.

- Amanda

Hi,

I was unable to reset it with baud rate of 1200…

At the end I have modified my program to take into account that the setup is not run on connect.

Here is a picture of my electronics for my robot arm.

thanks,

1 Like