RTC project doesn't work without open IDE serial monitor

Hello everybody,

I’m making a robotic clock with an Arduino Micro, a RTC DS1307 modul, one 9g servo for hour indication and two 9g servo to make a robotic arm to indicate minut.

The systeme is power by 12v 1.5A power suppli connect to Vin of the Arduino Micro, I use the regulate +5V of the bord to power servos and RTC with a 200uF capacitor.

My probleme is : Everything work good (RTC and Servos) ONLY when I open the serial monitor of the Arduino IDE whereas if I just plug USB or/and power the system with the external power suppli, servos don’t move and stay every time at the same position.

If I plug the USB and open the serial monitor, i can switch on the power suppli, close the monitor and take of the USB, the clock is working

If i just switch off and on the power suppli, the clock doesn’t work, servo stay in one position

#include <Wire.h>
#include "RTClib.h"
#include <Servo.h>

Servo servomin1;
Servo servomin2;
Servo servoheure;

RTC_DS1307 rtc;

//char daysOfTheWeek[7][12] = {"Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"};

void setup () {

  while (!Serial); // for Leonardo/Micro/Zero

  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
     //rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));

void loop () {
    DateTime now = rtc.now();
    //Serial.print(now.year(), DEC);
    //Serial.print(now.month(), DEC);
   // Serial.print(now.day(), DEC);
   // Serial.print(" (");
    Serial.print(now.hour(), DEC);
    Serial.print(now.minute(), DEC);
    Serial.print(now.second(), DEC);

   if (now.minute()== 1){
    if (now.minute()== 2){
    if (now.minute()== 3){
    if (now.minute()== 4){
    if (now.minute()== 5){
    if (now.minute()== 6){
    if (now.minute()== 7){
    if (now.minute()== 8){
    if (now.minute()== 9){
    if (now.minute()== 10{
                                       // .... the same until 60, cut because to much word for one post
     if (now.hour()== 1){                 
     if (now.hour()== 2){
     if (now.hour()== 3){
     if (now.hour()== 4){
     if (now.hour()== 5){
     if (now.hour()== 6){
     if (now.hour()== 7){
     if (now.hour()== 8){
     if (now.hour()== 9){
     if (now.hour()== 10){
     if (now.hour()== 11){
    if (now.hour()== 12){

delay (2000);

Please can you help me !

Thanks you

remove this line:

  while (!Serial); // for Leonardo/Micro/Zero

or place it under Serial.begin() if you have a Leonardo/Micro/Zero

I remove it, it's working !!!

thanks a lots!

I remove it, it's working !!!

thanks a lots!

Great, that line says "Wait here until a Serial connection is established." In your case, you asked for the Serial connection after that line, and well... it won't get there 'cuz its waiting, forever for something that won't happen.

thanks you an other time for the explanation!