Is there a main method in Arduino?

I am quite new to programming with Arduinos, and I am tring to get used to them haha.
I am programming a bot to drive autonomously. For now, I ust need the bot to move a certain distance forward, turn right, then move forward for a second and then stop.
I was wondering if there was a different method rather than loop()? I just want my bot to stop after the function is executed.
Thank you! :smiley:

setup()

Stop the motors, not the program.

The Arduino IDE builds a hidden main() function into the code when it is compiles. This is the main() function

/*
  main.cpp - Main loop for Arduino sketches
  Copyright (c) 2005-2013 Arduino Team.  All right reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include <Arduino.h>

// Declared weak in Arduino.h to allow user redefinitions.
int atexit(void (* /*func*/ )()) { return 0; }

// Weak empty variant initialization function.
// May be redefined by variant files.
void initVariant() __attribute__((weak));
void initVariant() { }

void setupUSB() __attribute__((weak));
void setupUSB() { }

int main(void)
{
 init();

 initVariant();

#if defined(USBCON)
 USBDevice.attach();
#endif
 
 setup();
    
 for (;;) {
 loop();
 if (serialEventRun) serialEventRun();
 }
        
 return 0;
}

If you provide your own main() function in the IDE then the hidden one will be ignored and yours will be used instead

Note, however, that you can do exactly as you describe with the standard Arduino setup() and loop() functions

I was wondering if there was a different method rather than loop()? I just want my bot to stop after the function is executed.

Programs generally don't work like that. The general idea is they run forever, well, at least as long as the power is on. You make the program start and stop whatever activity it is controlling, but the program itself continues to run. By way of analogy; you don't stop your body functioning when you finish whatever you are doing, your task ends but you continue to live.

I am quite new to programming with Arduinos

You need to work through the various examples on this web site, in the Arduino IDE and elsewhere. A word of warning, the very first example in the IDE shows you how to use delay(); to blink an LED. This is great for giving confidence to someone new as it's a quick way to achieve something. Unfortunately it sets a bad example because delay(); stops everything else working during the delay. Use the other examples to learn how to do stuff without using delay();.

If you get stuck, ask.